Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-kernel/Fragment/HIncludeFragmentRenderer.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
14 use Symfony\Component\HttpFoundation\Request; | 14 use Symfony\Component\HttpFoundation\Request; |
15 use Symfony\Component\HttpFoundation\Response; | 15 use Symfony\Component\HttpFoundation\Response; |
16 use Symfony\Component\Templating\EngineInterface; | 16 use Symfony\Component\Templating\EngineInterface; |
17 use Symfony\Component\HttpKernel\Controller\ControllerReference; | 17 use Symfony\Component\HttpKernel\Controller\ControllerReference; |
18 use Symfony\Component\HttpKernel\UriSigner; | 18 use Symfony\Component\HttpKernel\UriSigner; |
19 use Twig\Environment; | |
20 use Twig\Error\LoaderError; | |
21 use Twig\Loader\ExistsLoaderInterface; | |
19 | 22 |
20 /** | 23 /** |
21 * Implements the Hinclude rendering strategy. | 24 * Implements the Hinclude rendering strategy. |
22 * | 25 * |
23 * @author Fabien Potencier <fabien@symfony.com> | 26 * @author Fabien Potencier <fabien@symfony.com> |
30 private $charset; | 33 private $charset; |
31 | 34 |
32 /** | 35 /** |
33 * Constructor. | 36 * Constructor. |
34 * | 37 * |
35 * @param EngineInterface|\Twig_Environment $templating An EngineInterface or a \Twig_Environment instance | 38 * @param EngineInterface|Environment $templating An EngineInterface or a Twig instance |
36 * @param UriSigner $signer A UriSigner instance | 39 * @param UriSigner $signer A UriSigner instance |
37 * @param string $globalDefaultTemplate The global default content (it can be a template name or the content) | 40 * @param string $globalDefaultTemplate The global default content (it can be a template name or the content) |
38 * @param string $charset | 41 * @param string $charset |
39 */ | 42 */ |
40 public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null, $charset = 'utf-8') | 43 public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null, $charset = 'utf-8') |
41 { | 44 { |
42 $this->setTemplating($templating); | 45 $this->setTemplating($templating); |
43 $this->globalDefaultTemplate = $globalDefaultTemplate; | 46 $this->globalDefaultTemplate = $globalDefaultTemplate; |
46 } | 49 } |
47 | 50 |
48 /** | 51 /** |
49 * Sets the templating engine to use to render the default content. | 52 * Sets the templating engine to use to render the default content. |
50 * | 53 * |
51 * @param EngineInterface|\Twig_Environment|null $templating An EngineInterface or a \Twig_Environment instance | 54 * @param EngineInterface|Environment|null $templating An EngineInterface or an Environment instance |
52 * | 55 * |
53 * @throws \InvalidArgumentException | 56 * @throws \InvalidArgumentException |
54 */ | 57 */ |
55 public function setTemplating($templating) | 58 public function setTemplating($templating) |
56 { | 59 { |
57 if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof \Twig_Environment) { | 60 if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof Environment) { |
58 throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of \Twig_Environment or Symfony\Component\Templating\EngineInterface'); | 61 throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface'); |
59 } | 62 } |
60 | 63 |
61 $this->templating = $templating; | 64 $this->templating = $templating; |
62 } | 65 } |
63 | 66 |
134 return false; | 137 return false; |
135 } | 138 } |
136 } | 139 } |
137 | 140 |
138 $loader = $this->templating->getLoader(); | 141 $loader = $this->templating->getLoader(); |
139 if ($loader instanceof \Twig_ExistsLoaderInterface || method_exists($loader, 'exists')) { | 142 if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) { |
140 return $loader->exists($template); | 143 return $loader->exists($template); |
141 } | 144 } |
142 | 145 |
143 try { | 146 try { |
144 if (method_exists($loader, 'getSourceContext')) { | 147 if (method_exists($loader, 'getSourceContext')) { |
146 } else { | 149 } else { |
147 $loader->getSource($template); | 150 $loader->getSource($template); |
148 } | 151 } |
149 | 152 |
150 return true; | 153 return true; |
151 } catch (\Twig_Error_Loader $e) { | 154 } catch (LoaderError $e) { |
152 } | 155 } |
153 | 156 |
154 return false; | 157 return false; |
155 } | 158 } |
156 | 159 |