1 | <?php |
||
23 | class XmlSerializationVisitor extends AbstractVisitor |
||
24 | { |
||
25 | /** |
||
26 | * @var AccessorInterface |
||
27 | */ |
||
28 | private $accessor; |
||
29 | |||
30 | /** |
||
31 | * @var \DOMDocument|null |
||
32 | */ |
||
33 | private $document; |
||
34 | |||
35 | /** |
||
36 | * @var \DOMNode|null |
||
37 | */ |
||
38 | private $node; |
||
39 | |||
40 | /** |
||
41 | * @var \DOMNode[] |
||
42 | */ |
||
43 | private $stack; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | private $version; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | private $encoding; |
||
54 | |||
55 | /** |
||
56 | * @var string |
||
57 | */ |
||
58 | private $root; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | private $entry; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | private $entryAttribute; |
||
69 | |||
70 | /** |
||
71 | * @param AccessorInterface $accessor |
||
72 | * @param string $version |
||
73 | * @param string $encoding |
||
74 | * @param string $root |
||
75 | * @param string $entry |
||
76 | * @param string $entryAttribute |
||
77 | */ |
||
78 | 738 | public function __construct( |
|
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | 147 | public function prepare($data, ContextInterface $context) |
|
98 | { |
||
99 | 147 | $this->document = null; |
|
100 | 147 | $this->node = null; |
|
101 | 147 | $this->stack = []; |
|
102 | |||
103 | 147 | return parent::prepare($data, $context); |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | 9 | public function visitBoolean($data, TypeMetadataInterface $type, ContextInterface $context) |
|
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | 51 | public function visitData($data, TypeMetadataInterface $type, ContextInterface $context) |
|
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | 93 | public function visitString($data, TypeMetadataInterface $type, ContextInterface $context) |
|
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | 147 | public function getResult() |
|
150 | |||
151 | /** |
||
152 | * {@inheritdoc} |
||
153 | */ |
||
154 | 120 | protected function doVisitObjectProperty( |
|
182 | |||
183 | /** |
||
184 | * {@inheritdoc} |
||
185 | */ |
||
186 | 27 | protected function doVisitArray($data, TypeMetadataInterface $type, ContextInterface $context) |
|
210 | |||
211 | /** |
||
212 | * {@inheritdoc} |
||
213 | */ |
||
214 | 54 | private function visitText($data) |
|
218 | |||
219 | /** |
||
220 | * @param \DOMNode $node |
||
221 | * |
||
222 | * @return \DOMNode |
||
223 | */ |
||
224 | 141 | private function visitNode(\DOMNode $node) |
|
232 | |||
233 | /** |
||
234 | * @param \DOMNode $node |
||
235 | */ |
||
236 | 120 | private function enterNodeScope(\DOMNode $node) |
|
241 | |||
242 | 120 | private function leaveNodeScope() |
|
246 | |||
247 | /** |
||
248 | * @param string $data |
||
249 | * |
||
250 | * @return bool |
||
251 | */ |
||
252 | 93 | private function requireCData($data) |
|
256 | |||
257 | /** |
||
258 | * @return \DOMDocument |
||
259 | */ |
||
260 | 147 | private function getDocument() |
|
264 | |||
265 | /** |
||
266 | * @param string $name |
||
267 | * |
||
268 | * @return \DOMElement |
||
269 | */ |
||
270 | 120 | private function createNode($name) |
|
283 | |||
284 | /** |
||
285 | * @return \DOMDocument |
||
286 | */ |
||
287 | 147 | private function createDocument() |
|
297 | } |
||
298 |