1 | <?php |
||
53 | abstract class AbstractElementProcessor implements ElementProcessorInterface |
||
54 | { |
||
55 | /** |
||
56 | * Use the property processor methods |
||
57 | */ |
||
58 | use PropertyProcessorTrait; |
||
59 | |||
60 | /** |
||
61 | * Tag name / attribute map |
||
62 | * |
||
63 | * @var array |
||
64 | */ |
||
65 | protected static $tagNameAttributes = [ |
||
66 | 'META' => 'content', |
||
67 | 'AUDIO' => 'src', |
||
68 | 'EMBED' => 'src', |
||
69 | 'IFRAME' => 'src', |
||
70 | 'IMG' => 'src', |
||
71 | 'SOURCE' => 'src', |
||
72 | 'TRACK' => 'src', |
||
73 | 'VIDEO' => 'src', |
||
74 | 'A' => 'href', |
||
75 | 'AREA' => 'href', |
||
76 | 'LINK' => 'href', |
||
77 | 'OBJECT' => 'data', |
||
78 | 'DATA' => 'value', |
||
79 | 'METER' => 'value', |
||
80 | 'TIME' => 'datetime' |
||
81 | ]; |
||
82 | /** |
||
83 | * Property cache |
||
84 | * |
||
85 | * @var array |
||
86 | */ |
||
87 | protected $propertyCache = []; |
||
88 | /** |
||
89 | * HTML mode |
||
90 | * |
||
91 | * @var boolean |
||
92 | */ |
||
93 | protected $html; |
||
94 | |||
95 | /** |
||
96 | * Enable / disable HTML element value resolution |
||
97 | * |
||
98 | * @param bool $html Enable HTML element value resolution |
||
99 | * @return ElementProcessorInterface Self reference |
||
100 | */ |
||
101 | 14 | public function setHtml($html) |
|
106 | |||
107 | /** |
||
108 | * Process a DOM element's child |
||
109 | * |
||
110 | * @param \DOMElement $element DOM element |
||
111 | * @param ContextInterface $context Context |
||
112 | * @return ContextInterface Context for children |
||
113 | */ |
||
114 | 17 | public function processElementChildren(\DOMElement $element, ContextInterface $context) |
|
119 | |||
120 | /** |
||
121 | * Create a nested child |
||
122 | * |
||
123 | * @param \DOMElement $element DOM element |
||
124 | * @param ContextInterface $context Context |
||
125 | * @return ContextInterface Context for children |
||
126 | */ |
||
127 | abstract protected function processChild(\DOMElement $element, ContextInterface $context); |
||
128 | |||
129 | /** |
||
130 | * Return a thing by typeof value |
||
131 | * |
||
132 | * @param string|null $typeof Thing type |
||
133 | * @param string|null $resourceId Resource ID |
||
134 | * @param ContextInterface $context Context |
||
135 | * @return Thing Thing |
||
136 | * @throws RuntimeException If the default vocabulary is empty |
||
137 | */ |
||
138 | 17 | protected function getThing($typeof, $resourceId, ContextInterface $context) |
|
150 | |||
151 | /** |
||
152 | * Instantiate a type |
||
153 | * |
||
154 | * @param string $prefixedType Prefixed type |
||
155 | * @param ContextInterface $context Context |
||
156 | * @return TypeInterface Type |
||
157 | */ |
||
158 | 16 | protected function getType($prefixedType, ContextInterface $context) |
|
172 | |||
173 | /** |
||
174 | * Split a value into a vocabulary prefix and a name |
||
175 | * |
||
176 | * @param string $prefixName Prefixed name |
||
177 | * @return array Prefix and name |
||
178 | */ |
||
179 | abstract protected function getPrefixName($prefixName); |
||
180 | } |
||
181 |