From e7c0aea5871acf405d6925660e13ec29bc875097 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 29 Apr 2011 22:36:24 +0200 Subject: [PATCH] make Templating Engine $globals optional --- .../Bundle/FrameworkBundle/Templating/PhpEngine.php | 9 ++++++--- src/Symfony/Bundle/TwigBundle/TwigEngine.php | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php index b9ffe0379797..a93098eb842c 100755 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php @@ -32,14 +32,17 @@ class PhpEngine extends BasePhpEngine implements EngineInterface * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance * @param ContainerInterface $container The DI container * @param LoaderInterface $loader A loader instance - * @param GlobalVariables $globals A GlobalVariables instance + * @param GlobalVariables|null $globals A GlobalVariables instance or null */ - public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, GlobalVariables $globals) + public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, GlobalVariables $globals = null) { $this->container = $container; parent::__construct($parser, $loader); - $this->addGlobal('app', $globals); + + if (null !== $globals) { + $this->addGlobal('app', $globals); + } } /** diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index 5d3f9181ee35..30fae0656e3e 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -32,14 +32,16 @@ class TwigEngine implements EngineInterface * * @param \Twig_Environment $environment A \Twig_Environment instance * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance - * @param GlobalVariables $globals A GlobalVariables instance + * @param GlobalVariables|null $globals A GlobalVariables instance or null */ public function __construct(\Twig_Environment $environment, TemplateNameParserInterface $parser, GlobalVariables $globals) { $this->environment = $environment; $this->parser = $parser; - $environment->addGlobal('app', $globals); + if (null !== $globals) { + $environment->addGlobal('app', $globals); + } } /**