diff --git a/app/src/Domain/Repository/Channel/ChannelAggregateRepository.php b/app/src/Domain/Repository/Channel/ChannelAggregateRepository.php index d7b28b3..ded37a1 100644 --- a/app/src/Domain/Repository/Channel/ChannelAggregateRepository.php +++ b/app/src/Domain/Repository/Channel/ChannelAggregateRepository.php @@ -3,12 +3,13 @@ namespace Slovocast\Domain\Repository\Channel; use Slovocast\Domain\Entity\Episode; +use Slovocast\Domain\Entity\Channel; use Slovocast\Domain\Aggregate\ChannelAggregate; use Slovocast\Domain\Repository\Channel\ChannelRepositoryInterface; use Slovocast\Domain\Repository\Episode\EpisodeRepositoryInterface; use Slovocast\Infrastructure\Api\Database\DatabaseHandlerInterface; -class ChannelAggregateRepository +class ChannelAggregateRepository implements ChannelAggregateRepositoryInterface { public function __construct( protected DatabaseHandlerInterface $database, @@ -16,14 +17,20 @@ class ChannelAggregateRepository protected EpisodeRepositoryInterface $episodeRepository, ) { } - public function getChannelWithEpisodes(int $id): ChannelAggregate + public function get(int $id): ChannelAggregate { $channel = $this->channelRepository->get($id); $episodes = $this->episodeRepository->getFromChannel($channel); return new ChannelAggregate($channel, $episodes); } - public function getChannelByEpisode(Episode $episode): ChannelAggregate + public function getFromChannel(Channel $channel): ChannelAggregate + { + $episodes = $this->episodeRepository->getFromChannel($channel); + return new ChannelAggregate($channel, $episodes); + } + + public function getFromEpisode(Episode $episode): ChannelAggregate { $query = "SELECT c.id as channel_id, e.id as episode_id FROM channel c @@ -35,6 +42,6 @@ class ChannelAggregateRepository ]); $row = array_shift($results); - return $this->getChannelByEpisode($row['id']); + return $this->get($row['id']); } } diff --git a/app/src/Domain/Repository/Channel/ChannelAggregateRepositoryInterface.php b/app/src/Domain/Repository/Channel/ChannelAggregateRepositoryInterface.php new file mode 100644 index 0000000..dd9c3b1 --- /dev/null +++ b/app/src/Domain/Repository/Channel/ChannelAggregateRepositoryInterface.php @@ -0,0 +1,20 @@ +