feat: ajout de la gestion des sources de contenu avec des commandes et des gestionnaires pour l'importation, la mise à jour et l'exportation, ainsi que la création des ressources API correspondantes.

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-06-26 23:24:13 +02:00
parent ebcca466a9
commit 32b4e4fbb2
30 changed files with 1783 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Domain\Setting\Application\CommandHandler;
use App\Domain\Setting\Application\Command\UpsertContentSourceCommand;
use App\Domain\Setting\Domain\Contract\Repository\ContentSourceRepositoryInterface;
use App\Domain\Setting\Domain\Model\ContentSource;
readonly class UpsertContentSourceCommandHandler
{
public function __construct(
private ContentSourceRepositoryInterface $contentSourceRepository
) {}
public function handle(UpsertContentSourceCommand $command): void
{
if ($command->id) {
// Update existing
$contentSource = $this->contentSourceRepository->findById($command->id);
if ($contentSource) {
$contentSource->update(
baseUrl: $command->baseUrl,
chapterUrlFormat: $command->chapterUrlFormat,
scrapingType: $command->scrapingType,
imageSelector: $command->imageSelector,
nextPageSelector: $command->nextPageSelector,
chapterSelector: $command->chapterSelector,
);
$this->contentSourceRepository->save($contentSource);
}
} else {
// Create new
$contentSource = ContentSource::create(
baseUrl: $command->baseUrl,
chapterUrlFormat: $command->chapterUrlFormat,
scrapingType: $command->scrapingType,
imageSelector: $command->imageSelector,
nextPageSelector: $command->nextPageSelector,
chapterSelector: $command->chapterSelector,
);
$this->contentSourceRepository->save($contentSource);
}
}
}