getAttribute() публичный Метод

Return the attribute value under the defined $key.
public getAttribute ( string $key, mixed $defaultValue = false ) : mixed
$key string Attribute key.
$defaultValue mixed Default value that the method should return if $key is not found among the attributes.
Результат mixed
Пример #1
0
 /**
  * @dataProvider dataProvider
  */
 public function testSetGetAttribute(Plugin $p)
 {
     $p->setAttribute('attr1', 'val1');
     $p->setAttribute('attr2', 'val2');
     $this->assertSame('val1', $p->getAttribute('attr1'));
     $this->assertSame('val2', $p->getAttribute('attr2'));
     $this->assertFalse($p->getAttribute('attr3'));
     $this->assertSame('default', $p->getAttribute('attr4', 'default'));
 }
Пример #2
0
 /**
  * Register a plugin for the template engine.
  *
  * @param Plugin $plugin
  *
  * @throws \Exception|SmartyException
  * @return void
  */
 public function registerPlugin(Plugin $plugin)
 {
     try {
         $this->smarty->registerPlugin($plugin->getType(), $plugin->getName(), $plugin->getCallbackFunction(), $plugin->getAttribute('Cachable', true), $plugin->getAttribute('CacheAttr', null));
     } catch (\SmartyException $e) {
         throw new SmartyException($e);
     }
 }