chore: cleanup
This commit is contained in:
@@ -4,7 +4,7 @@ namespace App\Library\Action\Command;
|
||||
|
||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||
|
||||
class SearchCommand implements CommandInterface
|
||||
class LibrarySearchCommand implements CommandInterface
|
||||
{
|
||||
public function __construct(
|
||||
public ?string $term = null,
|
||||
@@ -3,16 +3,16 @@
|
||||
namespace App\Library\Action\Handler;
|
||||
|
||||
use App\Base\Service\MediaFiles;
|
||||
use App\Library\Action\Command\SearchCommand;
|
||||
use App\Library\Action\Result\SearchResult;
|
||||
use App\Library\Action\Command\LibrarySearchCommand;
|
||||
use App\Library\Action\Result\LibrarySearchResult;
|
||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||
use OneToMany\RichBundle\Contract\HandlerInterface;
|
||||
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||
|
||||
/**
|
||||
* @implements HandlerInterface<SearchCommand,SearchHandler>
|
||||
* @implements HandlerInterface<LibrarySearchCommand,LibrarySearchHandler>
|
||||
*/
|
||||
class SearchHandler implements HandlerInterface
|
||||
class LibrarySearchHandler implements HandlerInterface
|
||||
{
|
||||
private array $searchTypes = [
|
||||
'episode_by_title' => 'episodeByTitle',
|
||||
@@ -40,7 +40,7 @@ class SearchHandler implements HandlerInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
private function episodeByTitle(CommandInterface $command): ?SearchResult
|
||||
private function episodeByTitle(CommandInterface $command): ?LibrarySearchResult
|
||||
{
|
||||
$result = $this->mediaFiles->episodeExists(
|
||||
$command->title,
|
||||
@@ -50,14 +50,11 @@ class SearchHandler implements HandlerInterface
|
||||
|
||||
$exists = $result instanceof \SplFileInfo;
|
||||
|
||||
return new SearchResult(
|
||||
|
||||
return new LibrarySearchResult(
|
||||
input: $command,
|
||||
message: 'Success',
|
||||
code: 200,
|
||||
data: [
|
||||
'exists' => $exists,
|
||||
'file' => true === $exists ? ['filename' => $result->getFilename(), 'size' => $result->getSize()] : null,
|
||||
]
|
||||
exists: $exists,
|
||||
file: true === $exists ? $result->getFileInfo() : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace App\Library\Action\Input;
|
||||
|
||||
use App\Library\Action\Command\SearchCommand;
|
||||
use App\Library\Action\Command\LibrarySearchCommand;
|
||||
use OneToMany\RichBundle\Attribute\SourceQuery;
|
||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||
use OneToMany\RichBundle\Contract\InputInterface;
|
||||
|
||||
/**
|
||||
* @implements InputInterface<SearchInput, SearchCommand>
|
||||
* @implements InputInterface<LibrarySearchInput, LibrarySearchCommand>
|
||||
*/
|
||||
class SearchInput implements InputInterface
|
||||
class LibrarySearchInput implements InputInterface
|
||||
{
|
||||
public function __construct(
|
||||
#[SourceQuery('term', nullify: true)]
|
||||
@@ -27,7 +27,7 @@ class SearchInput implements InputInterface
|
||||
|
||||
public function toCommand(): CommandInterface
|
||||
{
|
||||
return new SearchCommand(
|
||||
return new LibrarySearchCommand(
|
||||
term: $this->term,
|
||||
title: $this->title,
|
||||
imdbId: $this->imdbId,
|
||||
@@ -4,12 +4,12 @@ namespace App\Library\Action\Result;
|
||||
|
||||
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||
|
||||
class SearchResult implements ResultInterface
|
||||
class LibrarySearchResult implements ResultInterface
|
||||
{
|
||||
public function __construct(
|
||||
public object|array $input,
|
||||
public string $message,
|
||||
public int $code,
|
||||
public ?array $data,
|
||||
public bool $exists,
|
||||
public ?\SplFileInfo $file = null,
|
||||
public ?object $ptn = null,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user