/** * @param string $view * @param array $parameters * @param Response $response * @return Response */ public function render($view, array $parameters = array(), Response $response = null) { if (array_key_exists('action', $parameters) && $parameters['action'] == 'edit') { $event = new CmsEvent($parameters['object']); $this->dispatcher->dispatch(CRUDController::EDIT_ENTITY, $event); } return parent::render($view, $parameters, $response); }
public function testRenderAjax() { $this->parameters = array(); $this->request->headers->set('X-Requested-With', 'XMLHttpRequest'); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $this->controller->render('FooAdminBundle::foo.html.twig', array('foo' => 'bar'))); $this->assertSame($this->admin, $this->parameters['admin']); $this->assertSame('SonataAdminBundle::ajax_layout.html.twig', $this->parameters['base_template']); $this->assertSame($this->pool, $this->parameters['admin_pool']); $this->assertSame('bar', $this->parameters['foo']); $this->assertSame('FooAdminBundle::foo.html.twig', $this->template); }
/** * {@inheritdoc} */ public function render($view, array $parameters = [], Response $response = null) { $action = array_key_value($parameters, 'action', $this->admin->getCurrentAction()); if ($this->isModalAction($action)) { $parameters['base_template'] = $this->getModalLayout(); $parameters['admin_pool'] = $this->get('sonata.admin.pool'); $parameters['admin'] = $this->admin; //By default, Pjax remove "X-Requested-With" header //but in some cases the modal is returned as Modal response, //Pjax plugin show this type of response using a modal, then is required restart the X-Requested-With header //to hide some contents in the view $this->getRequest()->headers->set('X-Requested-With', 'XMLHttpRequest'); $modal = $this->createModal($view, $parameters, $this->admin->getClassnameLabel(), $this->admin->getIcon()); $this->admin->configureModal($action, $modal); return $this->renderModal($modal); } return parent::render($view, $parameters, $response); }
/** * {@inheritdoc} */ public function render($view, array $parameters = array(), Response $response = null, Request $request = null) { $parameters['media_pool'] = $this->container->get('sonata.media.pool'); $parameters['persistent_parameters'] = $this->admin->getPersistentParameters(); return parent::render($view, $parameters, $response, $request); }
/** * @param string $view * @param array $parameters * @param Response $response * * @return Response */ public function render($view, array $parameters = array(), Response $response = null) { if ($parameters && isset($parameters['action'])) { switch ($parameters['action']) { case 'list': case 'edit': case 'create': if ($this->get('request')->getMethod() != 'POST') { $parameters['base_template'] = 'ApplicationSonataClientBundle::ajax_layout.html.twig'; } break; } } return parent::render($view, $parameters, $response); }
/** * @param string $view * @param array $parameters * @param Response $response * * @return Response */ public function render($view, array $parameters = array(), Response $response = null) { if ($parameters && isset($parameters['action'])) { switch ($parameters['action']) { case 'edit': case 'create': $parameters['base_template'] = $this->admin->getTemplate('ajax'); break; } } return parent::render($view, $parameters, $response); }