예제 #1
0
 /**
  * @param FormInterface $form
  *
  * @return FormView
  */
 private function createFormView(FormInterface $form)
 {
     $themes = $this->getParameterResolver()->resolveThemes();
     $view = $form->createView();
     if (!empty($themes)) {
         $this->formRenderer->setTheme($view, $themes);
     }
     return $view;
 }
예제 #2
0
 /**
  * @param ViewEvent $event
  */
 public function onView(ViewEvent $event)
 {
     if ($this->getParameterResolver()->resolveApi()) {
         return;
     }
     $view = $event->getView();
     $data = $grid = $view->getData();
     if (is_array($data) && isset($data['grid']) && $data['grid'] instanceof GridViewInterface) {
         $grid = $data['grid'];
     }
     if (!$grid instanceof GridViewInterface) {
         return;
     }
     if ($grid->getBatchForm() === null) {
         $batchForm = !isset($data['batch_form']) || !$data['batch_form'] instanceof FormInterface ? $this->formFactory->create(GridBatchType::class, null, ['grid' => $grid]) : $data['batch_form'];
         $grid->setBatchForm($batchForm->createView());
     }
     $themes = $this->getParameterResolver()->resolveThemes();
     if (!empty($themes)) {
         $this->formRenderer->setTheme($grid->getForm(), $themes);
         $this->formRenderer->setTheme($grid->getBatchForm(), $themes);
     }
     $view->setTemplateVar('grid')->setData($grid);
 }
예제 #3
0
 /**
  * Sets a theme for a given view.
  *
  * The theme format is "<Bundle>:<Controller>".
  *
  * @param FormView     $view   A FormView instance
  * @param string|array $themes A theme or an array of theme
  */
 public function setTheme(FormView $view, $themes)
 {
     $this->renderer->setTheme($view, $themes);
 }
예제 #4
0
 /**
  * Sets the theme(s) to be used for rendering a view and its children
  *
  * The theme format is "<Bundle>:<Controller>".
  *
  * @param BlockView       $view   The view to assign the theme(s) to
  * @param string|string[] $themes The theme(s). For example 'MuBundle:Layout/php'
  */
 public function setBlockTheme(BlockView $view, $themes)
 {
     $this->renderer->setTheme($view, $themes);
 }