feat: Reader beginning
This commit is contained in:
parent
e90c0a140e
commit
55945adc53
@@ -7,12 +7,15 @@ use App\Domain\Scraping\Domain\Exception\ChapterNotFoundException;
|
||||
use App\Domain\Scraping\Domain\Model\Chapter;
|
||||
use App\Entity\Chapter as EntityChapter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
class LegacyChapterRepository implements ChapterRepositoryInterface
|
||||
readonly class LegacyChapterRepository implements ChapterRepositoryInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private EntityManagerInterface $entityManager,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @throws ChapterNotFoundException
|
||||
*/
|
||||
public function getByMangaIdAndChapterNumber(string $mangaId, int $chapterNumber): Chapter
|
||||
{
|
||||
$chapterEntity = $this->entityManager->getRepository(EntityChapter::class)->findOneBy([
|
||||
@@ -31,4 +34,23 @@ class LegacyChapterRepository implements ChapterRepositoryInterface
|
||||
volumeNumber: $chapterEntity->getVolume(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ChapterNotFoundException
|
||||
*/
|
||||
public function save(Chapter $chapter): void
|
||||
{
|
||||
$chapterEntity = $this->entityManager->getRepository(EntityChapter::class)->findOneBy([
|
||||
'id' => $chapter->id,
|
||||
]);
|
||||
|
||||
if (!$chapterEntity) {
|
||||
throw new ChapterNotFoundException();
|
||||
}
|
||||
|
||||
$chapterEntity->setCbzPath($chapter->cbzPath);
|
||||
|
||||
$this->entityManager->persist($chapterEntity);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user