1 | <?php |
||
13 | class EmbedMetadata implements Interfaces\AttributeInterface, Interfaces\EmbedInterface, Interfaces\MixinInterface |
||
14 | { |
||
15 | /** |
||
16 | * Uses attributes. |
||
17 | */ |
||
18 | use Traits\AttributesTrait; |
||
19 | |||
20 | /** |
||
21 | * Uses embeds. |
||
22 | */ |
||
23 | use Traits\EmbedsTrait; |
||
24 | |||
25 | /** |
||
26 | * Uses mixins. |
||
27 | */ |
||
28 | use Traits\MixinsTrait; |
||
29 | |||
30 | /** |
||
31 | * Uses merged properties. |
||
32 | */ |
||
33 | use Traits\PropertiesTrait; |
||
34 | |||
35 | /** |
||
36 | * The embed name/key. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | public $name; |
||
41 | |||
42 | /** |
||
43 | * Constructor. |
||
44 | * |
||
45 | * @param string $name The embed name. |
||
46 | */ |
||
47 | public function __construct($name) |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | public function getProperties() |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | protected function applyMixinProperties(MixinMetadata $mixin) |
||
64 | { |
||
65 | foreach ($mixin->getAttributes() as $attribute) { |
||
66 | if (true === $this->hasAttribute($attribute->key)) { |
||
67 | throw MetadataException::mixinPropertyExists($this->name, $mixin->name, 'attribute', $attribute->key); |
||
68 | } |
||
69 | $this->addAttribute($attribute); |
||
70 | } |
||
71 | foreach ($mixin->getEmbeds() as $embed) { |
||
72 | if (true === $this->hasEmbed($embed->key)) { |
||
73 | throw MetadataException::mixinPropertyExists($this->name, $mixin->name, 'embed', $embed->key); |
||
74 | } |
||
75 | $this->addEmbed($embed); |
||
76 | } |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * {@inheritdoc} |
||
81 | */ |
||
82 | protected function validateAttribute(AttributeMetadata $attribute) |
||
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | protected function validateEmbed(EmbeddedPropMetadata $embed) |
||
98 | } |
||
99 |