feat: event listener sur MangaCreated pour ajouter les chapitres à la création

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-02-11 18:28:30 +01:00
parent 879b8fa2dc
commit 73774f84ff
10 changed files with 83 additions and 24 deletions

View File

@@ -9,7 +9,6 @@ class InMemoryMangadexClient implements MangadexClientInterface
private array $mangas = [];
private array $feeds = [];
private array $aggregates = [];
private array $mangaFeeds = [];
public function __construct(
array $mangas = [],
@@ -62,7 +61,22 @@ class InMemoryMangadexClient implements MangadexClientInterface
public function getMangaFeed(string $mangaId, int $offset = 0, int $limit = 500, string $order = 'asc'): array
{
return $this->mangaFeeds[$mangaId] ?? ['data' => []];
if (!isset($this->feeds[$mangaId])) {
return [
'data' => [],
'total' => 0
];
}
$feed = $this->feeds[$mangaId];
if ($order === 'desc') {
$feed = array_reverse($feed);
}
return [
'data' => array_slice($feed, $offset, $limit),
'total' => count($feed)
];
}
public function getMangaAggregate(string $mangaId): array
@@ -106,9 +120,4 @@ class InMemoryMangadexClient implements MangadexClientInterface
{
$this->aggregates[$mangaId] = $aggregate;
}
public function setMangaFeed(string $mangaId, array $feed): void
{
$this->mangaFeeds[$mangaId] = $feed;
}
}