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:
parent
7fe4ac0d3b
commit
37e1b202c2
@@ -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 = [];
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
Reference in New Issue
Block a user