| 1 |
<?php |
| 2 |
|
| 3 |
namespace ipl\Html\Contract; |
| 4 |
|
| 5 |
use ipl\Html\Attributes; |
| 6 |
|
| 7 |
/** |
| 8 |
* Options for decorators |
| 9 |
* |
| 10 |
* This trait is intended for use by the classes which implement {@see DecoratorOptionsInterface}. |
| 11 |
*/ |
| 12 |
trait DecoratorOptions |
| 13 |
{ |
| 14 |
/** @var ?Attributes Attributes of the decorator */ |
| 15 |
protected ?Attributes $attributes = null; |
| 16 |
|
| 17 |
/** |
| 18 |
* Get the attributes |
| 19 |
* |
| 20 |
* @return Attributes |
| 21 |
*/ |
| 22 |
public function getAttributes(): Attributes |
| 23 |
{ |
| 24 |
if ($this->attributes === null) { |
| 25 |
$this->attributes = new Attributes(); |
| 26 |
$this->registerAttributeCallbacks($this->attributes); |
| 27 |
} |
| 28 |
|
| 29 |
return $this->attributes; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Register attribute callbacks |
| 34 |
* |
| 35 |
* Override this method in order to register attribute callbacks in concrete classes. |
| 36 |
* |
| 37 |
* @param Attributes $attributes |
| 38 |
*/ |
| 39 |
abstract protected function registerAttributeCallbacks(Attributes $attributes): void; |
| 40 |
} |