Files
Mangarr/src/Domain/Setting/Infrastructure/Persistence/Mapper/ContentSourceMapper.php
ext.jeremy.guillot@maxicoffee.domains 795cbeccc3 feat(setting): étendre ContentSource avec champs de test et domain model
- Ajouter testSlug, testChapterNumber, baseUrl sur ContentSource (entité, domain model, migration)
- Exposer ces champs dans les Resources, Processors, Providers et Mapper
- Mettre à jour store Pinia, repository API et composants Vue (form, card, liste)
2026-03-16 00:11:17 +01:00

64 lines
2.8 KiB
PHP

<?php
namespace App\Domain\Setting\Infrastructure\Persistence\Mapper;
use App\Domain\Setting\Domain\Model\ContentSource;
use App\Entity\ContentSource as ContentSourceEntity;
readonly class ContentSourceMapper
{
public function toDomain(ContentSourceEntity $entity): ContentSource
{
return new ContentSource(
id: $entity->getId(),
baseUrl: $entity->getBaseUrl(),
chapterUrlFormat: $entity->getChapterUrlFormat(),
scrapingType: $entity->getScrapingType(),
imageSelector: $entity->getImageSelector(),
nextPageSelector: $entity->getNextPageSelector(),
chapterSelector: $entity->getChapterSelector(),
testSlug: $entity->getTestSlug(),
testChapterNumber: $entity->getTestChapterNumber(),
healthStatus: $entity->getHealthStatus(),
healthLastTestedAt: $entity->getHealthLastTestedAt(),
healthLastError: $entity->getHealthLastError(),
);
}
public function toEntity(ContentSource $contentSource): ContentSourceEntity
{
$entity = new ContentSourceEntity();
$entity->setBaseUrl($contentSource->getBaseUrl())
->setChapterUrlFormat($contentSource->getChapterUrlFormat())
->setScrapingType($contentSource->getScrapingType())
->setImageSelector($contentSource->getImageSelector())
->setNextPageSelector($contentSource->getNextPageSelector())
->setChapterSelector($contentSource->getChapterSelector())
->setTestSlug($contentSource->getTestSlug())
->setTestChapterNumber($contentSource->getTestChapterNumber())
->setHealthStatus($contentSource->getHealthStatus())
->setHealthLastTestedAt($contentSource->getHealthLastTestedAt())
->setHealthLastError($contentSource->getHealthLastError());
return $entity;
}
public function updateEntity(ContentSourceEntity $entity, ContentSource $contentSource): ContentSourceEntity
{
$entity->setBaseUrl($contentSource->getBaseUrl())
->setChapterUrlFormat($contentSource->getChapterUrlFormat())
->setScrapingType($contentSource->getScrapingType())
->setImageSelector($contentSource->getImageSelector())
->setNextPageSelector($contentSource->getNextPageSelector())
->setChapterSelector($contentSource->getChapterSelector())
->setTestSlug($contentSource->getTestSlug())
->setTestChapterNumber($contentSource->getTestChapterNumber())
->setHealthStatus($contentSource->getHealthStatus())
->setHealthLastTestedAt($contentSource->getHealthLastTestedAt())
->setHealthLastError($contentSource->getHealthLastError());
return $entity;
}
}