1 | <?php |
||
53 | trait PropertyProcessorTrait |
||
54 | { |
||
55 | /** |
||
56 | * Create a property by prefix and name |
||
57 | * |
||
58 | * @param string $prefix Property prefix |
||
59 | * @param string $name Property name |
||
60 | * @param \DOMElement $element DOM element |
||
61 | * @param ContextInterface $context Inherited Context |
||
62 | * @param boolean $last Last property |
||
63 | * @return ContextInterface Local context for this element |
||
64 | */ |
||
65 | 11 | protected function processPropertyPrefixName($prefix, $name, \DOMElement $element, ContextInterface $context, $last) |
|
78 | |||
79 | /** |
||
80 | * Return a vocabulary by prefix with fallback to the default vocabulary |
||
81 | * |
||
82 | * @param string $prefix Vocabulary prefix |
||
83 | * @param ContextInterface $context Context |
||
84 | * @return VocabularyInterface Vocabulary |
||
85 | */ |
||
86 | abstract protected function getVocabulary($prefix, ContextInterface $context); |
||
87 | |||
88 | /** |
||
89 | * Add a single property |
||
90 | * |
||
91 | * @param \DOMElement $element DOM element |
||
92 | * @param ContextInterface $context Inherited Context |
||
93 | * @param string $name Property name |
||
94 | * @param VocabularyInterface $vocabulary Property vocabulary |
||
95 | * @param boolean $last Last property |
||
96 | * @return ContextInterface Local context for this element |
||
97 | */ |
||
98 | 11 | protected function addProperty( |
|
116 | |||
117 | /** |
||
118 | * Return the resource ID |
||
119 | * |
||
120 | * @param \DOMElement $element DOM element |
||
121 | * @return string|null Resource ID |
||
122 | */ |
||
123 | abstract protected function getResourceId(\DOMElement $element); |
||
124 | |||
125 | /** |
||
126 | * Return a property value (type and tag name dependent) |
||
127 | * |
||
128 | * @param \DOMElement $element DOM element |
||
129 | * @param ContextInterface $context Context |
||
130 | * @return ThingInterface|string Property value |
||
131 | */ |
||
132 | 11 | protected function getPropertyValue(\DOMElement $element, ContextInterface $context) |
|
147 | |||
148 | /** |
||
149 | * Return a cached property value (if available) |
||
150 | * |
||
151 | * @param \DOMElement $element Element |
||
152 | * @return mixed|null Property value |
||
153 | */ |
||
154 | 11 | protected function getPropertyCache(\DOMElement $element) |
|
159 | |||
160 | /** |
||
161 | * Return a property child value |
||
162 | * |
||
163 | * @param \DOMElement $element DOM element |
||
164 | * @param ContextInterface $context Context |
||
165 | * @return ThingInterface|null Property child value |
||
166 | */ |
||
167 | abstract protected function getPropertyChildValue(\DOMElement $element, ContextInterface $context); |
||
168 | |||
169 | /** |
||
170 | * Cache a property value |
||
171 | * |
||
172 | * @param \DOMElement $element DOM element |
||
173 | * @param mixed $value Value |
||
174 | * @return mixed $value Value |
||
175 | */ |
||
176 | 11 | protected function setPropertyCache(\DOMElement $element, $value) |
|
180 | |||
181 | /** |
||
182 | * Return a property value (type and tag name dependent) |
||
183 | * |
||
184 | * @param \DOMElement $element DOM element |
||
185 | * @return string Property value |
||
186 | */ |
||
187 | 11 | protected function getPropertyStringValue(\DOMElement $element) |
|
203 | |||
204 | /** |
||
205 | * Return a content attribute property value |
||
206 | * |
||
207 | * @param \DOMElement $element DOM element |
||
208 | * @return null|string Property value |
||
209 | */ |
||
210 | 10 | protected function getPropertyContentAttrValue(\DOMElement $element) |
|
215 | |||
216 | /** |
||
217 | * Return a property value (type and tag name dependent) |
||
218 | * |
||
219 | * @param \DOMElement $element DOM element |
||
220 | * @return string|null Property value |
||
221 | */ |
||
222 | 10 | protected function getPropertyHtmlValue(\DOMElement $element) |
|
234 | |||
235 | /** |
||
236 | * Add a property child |
||
237 | * |
||
238 | * @param string|ThingInterface Property value |
||
239 | * @param ContextInterface $context Inherited Context |
||
240 | * @param boolean $last Last property |
||
241 | * @return ContextInterface Local context for this element |
||
242 | */ |
||
243 | 11 | protected function addPropertyChild($propertyValue, ContextInterface $context, $last) |
|
253 | |||
254 | /** |
||
255 | * Create a property |
||
256 | * |
||
257 | * @param \DOMElement $element DOM element |
||
258 | * @param ContextInterface $context Inherited Context |
||
259 | * @return ContextInterface Local context for this element |
||
260 | */ |
||
261 | abstract protected function processProperty(\DOMElement $element, ContextInterface $context); |
||
262 | } |
||
263 |