feat: debut rerefonte DDD CQRS

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-01-31 19:23:02 +01:00
committed by ThysTips
parent 8f7b5d71c5
commit 0c8ca6cca9
16 changed files with 483 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Domain\Scraping\Application\Command\ScrapeChapter;
use App\Domain\Scraping\Domain\Contract\ScraperInterface;
use App\Domain\Scraping\Domain\Repository\ScrapingJobRepositoryInterface;
use App\Domain\Scraping\Domain\Event\ChapterScrapingStarted;
use Symfony\Component\Messenger\MessageBusInterface;
class ScrapeChapterHandler
{
public function __construct(
private readonly ScraperInterface $scraper,
private readonly ScrapingJobRepositoryInterface $scrapingJobRepository,
private readonly MessageBusInterface $eventBus
) {}
public function handle(ScrapeChapterCommand $command): void
{
$job = $this->scraper->createScrapingJob(
$command->chapterId,
$command->sourceId
);
$this->scrapingJobRepository->save($job);
$this->eventBus->dispatch(new ChapterScrapingStarted($job->getId()));
$this->scraper->scrape($job);
}
}