feat: debut rerefonte DDD CQRS
This commit is contained in:
committed by
ThysTips
parent
8f7b5d71c5
commit
0c8ca6cca9
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user