addGlobal() public method

Registers a Global
public addGlobal ( string $name, mixed $value )
$name string The global name
$value mixed The global value
 public function testAddGlobal()
 {
     $obj = new Twig(['paths' => __DIR__ . '/../templates/']);
     $obj->addGlobal('sitename', 'Twig Test Site');
     $output = $obj->render('global');
     $this->assertEquals('<title>Twig Test Site</title>' . "\n", $output);
 }
Example #2
0
 /**
  * Назначить текущую тему оформления
  *
  * @param null $theme
  */
 static function setCurrent($theme = null)
 {
     //удалить все невостребованные классы тем оформления
     foreach (self::getThemes() as $t) {
         \LaraPage::body()->removeClass(self::getClassTheme($t));
     }
     //добавить класс текущей темы оформления
     \LaraPage::body()->addClass(self::getClassTheme($theme));
     self::$current = $theme;
     \Twig::addGlobal('current_theme', $theme);
 }