Symfony\Bundle\FrameworkBundle\Controller\Controller::render PHP Method

render() protected method

Renders a view.
protected render ( string $view, array $parameters = [], Response $response = null ) : Response
$view string The view name
$parameters array An array of parameters to pass to the view
$response Symfony\Component\HttpFoundation\Response A response instance
return Symfony\Component\HttpFoundation\Response A Response instance
    protected function render($view, array $parameters = array(), Response $response = null)
    {
        if ($this->container->has('templating')) {
            return $this->container->get('templating')->renderResponse($view, $parameters, $response);
        }
        if (!$this->container->has('twig')) {
            throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available.');
        }
        if (null === $response) {
            $response = new Response();
        }
        $response->setContent($this->container->get('twig')->render($view, $parameters));
        return $response;
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function render($view, array $parameters = array(), Response $response = null)
 {
     $parameters['admin'] = isset($parameters['admin']) ? $parameters['admin'] : $this->admin;
     $parameters['base_template'] = isset($parameters['base_template']) ? $parameters['base_template'] : $this->getBaseTemplate();
     $parameters['admin_pool'] = $this->get('sonata.admin.pool');
     return parent::render($view, $parameters, $response);
 }
All Usage Examples Of Symfony\Bundle\FrameworkBundle\Controller\Controller::render