added a proper setter for the templating servicein HInclude
This commit is contained in:
parent
63bfd9ef79
commit
a3131882e3
@ -41,7 +41,7 @@ class ContainerAwareHIncludeFragmentRenderer extends HIncludeFragmentRenderer
|
|||||||
public function render($uri, Request $request, array $options = array())
|
public function render($uri, Request $request, array $options = array())
|
||||||
{
|
{
|
||||||
if (!$this->templating) {
|
if (!$this->templating) {
|
||||||
$this->templating = $this->container->get('templating');
|
$this->setTemplating($this->container->get('templating'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::render($uri, $request, $options);
|
return parent::render($uri, $request, $options);
|
||||||
|
@ -24,10 +24,9 @@ use Symfony\Component\HttpKernel\UriSigner;
|
|||||||
*/
|
*/
|
||||||
class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||||
{
|
{
|
||||||
protected $templating;
|
|
||||||
|
|
||||||
private $globalDefaultTemplate;
|
private $globalDefaultTemplate;
|
||||||
private $signer;
|
private $signer;
|
||||||
|
private $templating;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -37,14 +36,24 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
|||||||
* @param string $globalDefaultTemplate The global default content (it can be a template name or the content)
|
* @param string $globalDefaultTemplate The global default content (it can be a template name or the content)
|
||||||
*/
|
*/
|
||||||
public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null)
|
public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null)
|
||||||
|
{
|
||||||
|
$this->setTemplating($templating);
|
||||||
|
$this->globalDefaultTemplate = $globalDefaultTemplate;
|
||||||
|
$this->signer = $signer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the templating engine to use to render the default content.
|
||||||
|
*
|
||||||
|
* @param EngineInterface|\Twig_Environment|null $templating An EngineInterface or a \Twig_Environment instance
|
||||||
|
*/
|
||||||
|
public function setTemplating($templating)
|
||||||
{
|
{
|
||||||
if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof \Twig_Environment) {
|
if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof \Twig_Environment) {
|
||||||
throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of \Twig_Environment or Symfony\Component\Templating\EngineInterface');
|
throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of \Twig_Environment or Symfony\Component\Templating\EngineInterface');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->templating = $templating;
|
$this->templating = $templating;
|
||||||
$this->globalDefaultTemplate = $globalDefaultTemplate;
|
|
||||||
$this->signer = $signer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user