vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigEngine.php line 49

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\TwigBundle;
  11. use Symfony\Bridge\Twig\TwigEngine as BaseEngine;
  12. use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
  13. use Symfony\Component\Config\FileLocatorInterface;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\Templating\TemplateNameParserInterface;
  16. use Twig\Environment;
  17. use Twig\Error\Error;
  18. /**
  19.  * This engine renders Twig templates.
  20.  *
  21.  * @author Fabien Potencier <fabien@symfony.com>
  22.  */
  23. class TwigEngine extends BaseEngine implements EngineInterface
  24. {
  25.     protected $locator;
  26.     public function __construct(Environment $environmentTemplateNameParserInterface $parserFileLocatorInterface $locator)
  27.     {
  28.         parent::__construct($environment$parser);
  29.         $this->locator $locator;
  30.     }
  31.     /**
  32.      * {@inheritdoc}
  33.      *
  34.      * @throws Error if something went wrong like a thrown exception while rendering the template
  35.      */
  36.     public function renderResponse($view, array $parameters = [], Response $response null)
  37.     {
  38.         if (null === $response) {
  39.             $response = new Response();
  40.         }
  41.         $response->setContent($this->render($view$parameters));
  42.         return $response;
  43.     }
  44. }