You are here

protected function Twig_Environment::initGlobals in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/Environment.php \Twig_Environment::initGlobals()
2 calls to Twig_Environment::initGlobals()
Twig_Environment::addGlobal in vendor/twig/twig/lib/Twig/Environment.php
Registers a Global.
Twig_Environment::getGlobals in vendor/twig/twig/lib/Twig/Environment.php
Gets the registered Globals.

File

vendor/twig/twig/lib/Twig/Environment.php, line 1264

Class

Twig_Environment
Stores the Twig configuration.

Code

protected function initGlobals() {
  $globals = array();
  foreach ($this->extensions as $name => $extension) {
    if (!$extension instanceof Twig_Extension_GlobalsInterface) {
      $m = new ReflectionMethod($extension, 'getGlobals');
      if ('Twig_Extension' !== $m
        ->getDeclaringClass()
        ->getName()) {
        @trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension is deprecated without explicitly implementing Twig_Extension_GlobalsInterface.', $name), E_USER_DEPRECATED);
      }
    }
    $extGlob = $extension
      ->getGlobals();
    if (!is_array($extGlob)) {
      throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
    }
    $globals[] = $extGlob;
  }
  $globals[] = $this->staging
    ->getGlobals();
  return call_user_func_array('array_merge', $globals);
}