src/Twig/VarsTwig.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Entity\Taxonomy\Taxon;
  4. use BitBag\SyliusElasticsearchPlugin\Form\Type\SearchType;
  5. use BitBag\SyliusElasticsearchPlugin\Model\Search;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Sylius\Component\Locale\Context\LocaleContextInterface;
  8. use Symfony\Component\Form\FormFactoryInterface;
  9. use Symfony\Component\Routing\RouterInterface;
  10. class VarsTwig
  11. {
  12.     private $em;
  13.     private $localeContext;
  14.     private $formFactory;
  15.     private $router;
  16.     public function __construct(EntityManagerInterface $emLocaleContextInterface $localeContextFormFactoryInterface $formFactoryRouterInterface $router)
  17.     {
  18.         $this->em $em;
  19.         $this->localeContext $localeContext;
  20.         $this->formFactory $formFactory;
  21.         $this->router $router;
  22.     }
  23.     public function taxons() {
  24.         return $this->em->getRepository(Taxon::class)->findRootNodes();
  25.     }
  26.     public function locale() {
  27.         return $this->localeContext->getLocaleCode();
  28.     }
  29.     public function searchForm() {
  30.         return $this->formFactory
  31.             ->create(SearchType::class, new Search(), ['action' => $this->router->generate('bitbag_sylius_elasticsearch_plugin_shop_search')]);
  32.     }
  33. }