@@ -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