feat: ajout de la gestion des commandes pour la suppression des fichiers CBZ et des chapitres, avec création des gestionnaires et des ressources API correspondantes

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-06-29 18:33:33 +02:00
parent 7fe4ac0d3b
commit 37e1b202c2
42 changed files with 1413 additions and 21 deletions

View File

@@ -44,6 +44,23 @@ class InMemoryMangaRepository implements MangaRepositoryInterface
$this->mangas[$manga->getId()] = $manga;
}
public function updatePreferredSources(string $mangaId, array $sourceIds): void
{
if (isset($this->mangas[$mangaId])) {
$manga = $this->mangas[$mangaId];
$updatedManga = new Manga(
$manga->getId(),
$manga->getTitle(),
$manga->getSlug(),
$manga->getDescription(),
$manga->getAuthor(),
$manga->getPublicationYear(),
$sourceIds // Mise à jour des sources préférées
);
$this->mangas[$mangaId] = $updatedManga;
}
}
public function clear(): void
{
$this->mangas = [];

View File

@@ -50,6 +50,42 @@ class InMemorySourceRepository implements SourceRepositoryInterface
$this->sources[$source->getId()->getValue()] = $source;
}
public function validateSourcesExist(array $sourceIds): bool
{
foreach ($sourceIds as $sourceId) {
$source = $this->sources[$sourceId] ?? null;
if (!$source || !$source->isActive()) {
return false;
}
}
return true;
}
/**
* @return Source[]
*/
public function getByIds(array $sourceIds): array
{
$sources = [];
foreach ($sourceIds as $sourceId) {
if (isset($this->sources[$sourceId])) {
$sources[] = $this->sources[$sourceId];
}
}
return $sources;
}
/**
* @return Source[]
*/
public function getAllActive(): array
{
return array_filter(
array_values($this->sources),
fn(Source $source) => $source->isActive()
);
}
public function clear(): void
{
$this->sources = [];