chore: cleanup

This commit is contained in:
2025-07-13 21:27:54 -05:00
parent accfa9c9bf
commit b42981b2a1
8 changed files with 27 additions and 31 deletions

View File

@@ -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,

View File

@@ -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,
);
}
}

View File

@@ -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,

View File

@@ -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,
) {}
}

View File

@@ -2,9 +2,9 @@
namespace App\Library\Framework\Controller;
use App\Library\Action\Handler\SearchHandler;
use App\Library\Action\Input\SearchInput;
use App\Library\Action\Result\SearchResult;
use App\Library\Action\Handler\LibrarySearchHandler;
use App\Library\Action\Input\LibrarySearchInput;
use App\Library\Action\Result\LibrarySearchResult;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -14,7 +14,7 @@ use Symfony\UX\Turbo\TurboBundle;
class Api extends AbstractController
{
#[Route('/api/library/search', name: 'api.library.search', methods: ['GET'])]
public function search(SearchInput $input, SearchHandler $handler, Request $request): Response
public function search(LibrarySearchInput $input, LibrarySearchHandler $handler, Request $request): Response
{
$result = $handler->handle($input->toCommand());
@@ -25,7 +25,7 @@ class Api extends AbstractController
return $this->json($handler->handle($input->toCommand()));
}
private function sendFragmentResponse(SearchResult $result, Request $request): Response
private function sendFragmentResponse(LibrarySearchResult $result, Request $request): Response
{
$request->setRequestFormat(TurboBundle::STREAM_FORMAT);
return $this->renderBlock(