Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a313188

Browse files
committed
added a proper setter for the templating servicein HInclude
1 parent 63bfd9e commit a313188

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(ContainerInterface $container, UriSigner $signer = n
4141
public function render($uri, Request $request, array $options = array())
4242
{
4343
if (!$this->templating) {
44-
$this->templating = $this->container->get('templating');
44+
$this->setTemplating($this->container->get('templating'));
4545
}
4646

4747
return parent::render($uri, $request, $options);

src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
*/
2525
class HIncludeFragmentRenderer extends RoutableFragmentRenderer
2626
{
27-
protected $templating;
28-
2927
private $globalDefaultTemplate;
3028
private $signer;
29+
private $templating;
3130

3231
/**
3332
* Constructor.
@@ -37,14 +36,24 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
3736
* @param string $globalDefaultTemplate The global default content (it can be a template name or the content)
3837
*/
3938
public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null)
39+
{
40+
$this->setTemplating($templating);
41+
$this->globalDefaultTemplate = $globalDefaultTemplate;
42+
$this->signer = $signer;
43+
}
44+
45+
/**
46+
* Sets the templating engine to use to render the default content.
47+
*
48+
* @param EngineInterface|\Twig_Environment|null $templating An EngineInterface or a \Twig_Environment instance
49+
*/
50+
public function setTemplating($templating)
4051
{
4152
if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof \Twig_Environment) {
4253
throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of \Twig_Environment or Symfony\Component\Templating\EngineInterface');
4354
}
4455

4556
$this->templating = $templating;
46-
$this->globalDefaultTemplate = $globalDefaultTemplate;
47-
$this->signer = $signer;
4857
}
4958

5059
/**

0 commit comments

Comments
 (0)