Skip to content

Commit

Permalink
make Templating Engine $globals optional
Browse files Browse the repository at this point in the history
  • Loading branch information
igorw committed Apr 29, 2011
1 parent f8cc8a7 commit e7c0aea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php
Expand Up @@ -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);
}
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Symfony/Bundle/TwigBundle/TwigEngine.php
Expand Up @@ -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);
}
}

/**
Expand Down

0 comments on commit e7c0aea

Please sign in to comment.