src/Twig/SearchByKeywordsExtension.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Service\SearchByKeywordsService;
  4. use Symfony\Component\Form\FormView;
  5. use Twig\Extension\AbstractExtension;
  6. use Twig\TwigFunction;
  7. class SearchByKeywordsExtension extends AbstractExtension
  8. {
  9.     public function __construct(
  10.         private SearchByKeywordsService $searchByKeywordsService
  11.     ) {}
  12.     public function getFunctions()
  13.     {
  14.         return [
  15.             new TwigFunction('search_by_keywords_form', [$this'getSearchByKeywordsFormView']),
  16.         ];
  17.     }
  18.     public function getSearchByKeywordsFormView(): FormView
  19.     {
  20.         return $this->searchByKeywordsService->getSearchByKeywordsForm()->createView();
  21.     }
  22. }