Bolt\Twig\TwigExtension::getGlobals PHP Method

getGlobals() public method

As of Twig 2.x, the ability to register a global variable after runtime or the extensions have been initialized will not be possible any longer, but changing the value of an already registered global is possible.
public getGlobals ( )
    public function getGlobals()
    {
        return ['bolt_name' => null, 'bolt_version' => null, 'bolt_stable' => null, 'frontend' => null, 'backend' => null, 'async' => null, 'paths' => null, 'theme' => null, 'user' => null, 'users' => null, 'config' => null];
    }

Usage Example

Example #1
0
 public function testGetGlobalsSafe()
 {
     $app = $this->getApp();
     $request = Request::createFromGlobals();
     $app['request'] = $request;
     $app['request_stack']->push($request);
     $handlers = $this->getTwigHandlers($app);
     $twig = new TwigExtension($app, $handlers, true);
     $result = $twig->getGlobals();
     $this->assertArrayHasKey('config', $result);
     $this->assertNull($result['config']);
     $this->assertNull($result['users']);
 }
All Usage Examples Of Bolt\Twig\TwigExtension::getGlobals