Skip to content

Commit f2691e1

Browse files
authored
Merge pull request #35 from Onefivefournine/master
Inherit twig globals
2 parents 8c18db4 + c95eac0 commit f2691e1

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Jade/JadeSymfonyEngine.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,21 @@ public function __construct($kernel)
9797
], ($container->hasParameter('pug') ? $container->getParameter('pug') : null) ?: []));
9898
$this->registerHelpers($container, array_slice(func_get_args(), 1));
9999
$this->assets = new Assets($this->jade);
100-
$app = new AppVariable();
101-
$app->setDebug($kernel->isDebug());
102-
$app->setEnvironment($environment);
103-
$app->setRequestStack($container->get('request_stack'));
104-
// @codeCoverageIgnoreStart
105-
if ($container->has('security.token_storage')) {
106-
$app->setTokenStorage($container->get('security.token_storage'));
100+
101+
foreach ($container->get('twig')->getGlobals() as $globalKey => $globalValue) {
102+
if ($globalValue instanceof AppVariable) {
103+
$globalValue->setDebug($kernel->isDebug());
104+
$globalValue->setEnvironment($environment);
105+
$globalValue->setRequestStack($container->get('request_stack'));
106+
// @codeCoverageIgnoreStart
107+
if ($container->has('security.token_storage')) {
108+
$globalValue->setTokenStorage($container->get('security.token_storage'));
109+
}
110+
// @codeCoverageIgnoreEnd
111+
}
112+
113+
$this->share($globalKey, $globalValue);
107114
}
108-
// @codeCoverageIgnoreEnd
109-
$this->share('app', $app);
110115
}
111116

112117
protected function getEngineClassName()

0 commit comments

Comments
 (0)