Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function renderFilter(GridView $gridView, Filter $filter)
 {
     if (!isset($this->filterTemplates[$type = $filter->getType()])) {
         throw new \InvalidArgumentException(sprintf('Missing template for filter type "%s".', $type));
     }
     $form = $this->formFactory->createNamed('criteria', 'form', [], ['csrf_protection' => false, 'required' => false]);
     $form->add($filter->getName(), sprintf('sylius_grid_filter_%s', $filter->getType()), $filter->getOptions());
     $criteria = $gridView->getParameters()->get('criteria', []);
     $form->submit($criteria);
     return $this->twig->render($this->filterTemplates[$type], ['grid' => $gridView, 'filter' => $filter, 'form' => $form->get($filter->getName())->createView()]);
 }
Exemple #2
0
 /**
  * @param Filter $filter
  *
  * @return string
  *
  * @throws \InvalidArgumentException
  */
 private function getFilterTemplate(Filter $filter)
 {
     $template = $filter->getTemplate();
     if (null !== $template) {
         return $template;
     }
     $type = $filter->getType();
     if (!isset($this->filterTemplates[$type])) {
         throw new \InvalidArgumentException(sprintf('Missing template for filter type "%s".', $type));
     }
     return $this->filterTemplates[$type];
 }