<?php
namespace App\Twig;
use App\Entity\Taxonomy\Taxon;
use BitBag\SyliusElasticsearchPlugin\Form\Type\SearchType;
use BitBag\SyliusElasticsearchPlugin\Model\Search;
use Doctrine\ORM\EntityManagerInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Routing\RouterInterface;
class VarsTwig
{
private $em;
private $localeContext;
private $formFactory;
private $router;
public function __construct(EntityManagerInterface $em, LocaleContextInterface $localeContext, FormFactoryInterface $formFactory, RouterInterface $router)
{
$this->em = $em;
$this->localeContext = $localeContext;
$this->formFactory = $formFactory;
$this->router = $router;
}
public function taxons() {
return $this->em->getRepository(Taxon::class)->findRootNodes();
}
public function locale() {
return $this->localeContext->getLocaleCode();
}
public function searchForm() {
return $this->formFactory
->create(SearchType::class, new Search(), ['action' => $this->router->generate('bitbag_sylius_elasticsearch_plugin_shop_search')]);
}
}