Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function getRawValue(ResultRecordInterface $record)
 {
     $label = null;
     try {
         $label = $record->getValue($this->getOr(self::DATA_NAME_KEY, $this->get(self::NAME_KEY)));
     } catch (\LogicException $e) {
     }
     return $this->twig->loadTemplate(self::TEMPLATE)->render(['url' => parent::getRawValue($record), 'label' => $label]);
 }
Beispiel #2
0
 public function testGlobals()
 {
     // globals can be added after calling getGlobals
     $twig = new Environment(new \Twig_Loader_String());
     $twig->addGlobal('foo', 'foo');
     $twig->getGlobals();
     $twig->addGlobal('foo', 'bar');
     $globals = $twig->getGlobals();
     $this->assertEquals('bar', $globals['foo']);
     // globals can be modified after runtime init
     $twig = new Environment(new \Twig_Loader_String());
     $twig->addGlobal('foo', 'foo');
     $twig->getGlobals();
     $twig->initRuntime();
     $twig->addGlobal('foo', 'bar');
     $globals = $twig->getGlobals();
     $this->assertEquals('bar', $globals['foo']);
     // globals can be modified after extensions init
     $twig = new Environment(new \Twig_Loader_String());
     $twig->addGlobal('foo', 'foo');
     $twig->getGlobals();
     $twig->getFunctions();
     $twig->addGlobal('foo', 'bar');
     $globals = $twig->getGlobals();
     $this->assertEquals('bar', $globals['foo']);
     // globals can be modified after extensions and runtime init
     $twig = new Environment(new \Twig_Loader_String());
     $twig->addGlobal('foo', 'foo');
     $twig->getGlobals();
     $twig->getFunctions();
     $twig->initRuntime();
     $twig->addGlobal('foo', 'bar');
     $globals = $twig->getGlobals();
     $this->assertEquals('bar', $globals['foo']);
     $twig = new Environment(new \Twig_Loader_String());
     $twig->getGlobals();
     $twig->addGlobal('foo', 'bar');
     $template = $twig->loadTemplate('{{foo}}');
     $this->assertEquals('bar', $template->render(array()));
 }