Webiny\Component\TemplateEngine\Plugin::setAttribute PHP Method

setAttribute() public method

Sets an optional attribute to the plugin.
public setAttribute ( string $key, mixed $value )
$key string Attribute key.
$value mixed Attribute value.
    public function setAttribute($key, $value)
    {
        $this->attributes->key($key, $value);
    }

Usage Example

Example #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'));
 }