Files
Mangarr/src/Twig/Components/MangaSearch.php
Jérémy Guillot ba30d3102d Added:
- new simpler modal without bootstrap
- new loadingbutton component
- cleanupsome old code
- toolbar adjusments
2024-06-30 12:44:41 +02:00

36 lines
782 B
PHP

<?php
namespace App\Twig\Components;
use App\Service\MangadexProvider;
use Doctrine\Common\Collections\Collection;
use Exception;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\DefaultActionTrait;
#[AsLiveComponent]
class MangaSearch
{
use DefaultActionTrait;
#[LiveProp(writable: true)]
public ?string $query = null;
public function __construct(private readonly MangadexProvider $mangadexProvider)
{
}
/**
* @throws Exception
*/
public function getMangas(): Collection|null
{
if ($this->query === null || $this->query === '') {
return null;
}
return $this->mangadexProvider->search($this->query);
}
}