feat: media result page
This commit is contained in:
14
src/Search/Action/Command/GetMediaInfoCommand.php
Normal file
14
src/Search/Action/Command/GetMediaInfoCommand.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Search\Action\Command;
|
||||
|
||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||
|
||||
class GetMediaInfoCommand implements CommandInterface
|
||||
{
|
||||
/** @implements CommandInterface<GetMediaInfoCommand> */
|
||||
public function __construct(
|
||||
public string $tmdbId,
|
||||
public string $mediaType,
|
||||
) {}
|
||||
}
|
||||
23
src/Search/Action/Handler/GetMediaInfoHandler.php
Normal file
23
src/Search/Action/Handler/GetMediaInfoHandler.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Search\Action\Handler;
|
||||
|
||||
use App\Search\Action\Result\GetMediaInfoResult;
|
||||
use App\Tmdb\Tmdb;
|
||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||
use OneToMany\RichBundle\Contract\HandlerInterface;
|
||||
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||
|
||||
class GetMediaInfoHandler implements HandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Tmdb $tmdb,
|
||||
) {}
|
||||
|
||||
public function handle(CommandInterface $command): ResultInterface
|
||||
{
|
||||
$media = $this->tmdb->mediaDetails($command->tmdbId, $command->mediaType);
|
||||
|
||||
return new GetMediaInfoResult($media);
|
||||
}
|
||||
}
|
||||
25
src/Search/Action/Input/GetMediaInfoInput.php
Normal file
25
src/Search/Action/Input/GetMediaInfoInput.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Search\Action\Input;
|
||||
|
||||
use App\Download\Action\Command\GetDownloadOptionsCommand;
|
||||
use App\Search\Action\Command\GetMediaInfoCommand;
|
||||
use OneToMany\RichBundle\Attribute\SourceRoute;
|
||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||
use OneToMany\RichBundle\Contract\InputInterface;
|
||||
|
||||
class GetMediaInfoInput implements InputInterface
|
||||
{
|
||||
public function __construct(
|
||||
#[SourceRoute('tmdbId')]
|
||||
public string $tmdbId,
|
||||
|
||||
#[SourceRoute('mediaType')]
|
||||
public string $mediaType,
|
||||
) {}
|
||||
|
||||
public function toCommand(): CommandInterface
|
||||
{
|
||||
return new GetMediaInfoCommand($this->tmdbId, $this->mediaType);
|
||||
}
|
||||
}
|
||||
14
src/Search/Action/Result/GetMediaInfoResult.php
Normal file
14
src/Search/Action/Result/GetMediaInfoResult.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Search\Action\Result;
|
||||
|
||||
use App\Tmdb\TmdbResult;
|
||||
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||
|
||||
class GetMediaInfoResult implements ResultInterface
|
||||
{
|
||||
/** @implements ResultInterface<GetMediaInfoResult> */
|
||||
public function __construct(
|
||||
public TmdbResult $media,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user