comparison vendor/symfony/console/Descriptor/XmlDescriptor.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children c2387f117808
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
25 * @internal 25 * @internal
26 */ 26 */
27 class XmlDescriptor extends Descriptor 27 class XmlDescriptor extends Descriptor
28 { 28 {
29 /** 29 /**
30 * @param InputDefinition $definition
31 *
32 * @return \DOMDocument 30 * @return \DOMDocument
33 */ 31 */
34 public function getInputDefinitionDocument(InputDefinition $definition) 32 public function getInputDefinitionDocument(InputDefinition $definition)
35 { 33 {
36 $dom = new \DOMDocument('1.0', 'UTF-8'); 34 $dom = new \DOMDocument('1.0', 'UTF-8');
48 46
49 return $dom; 47 return $dom;
50 } 48 }
51 49
52 /** 50 /**
53 * @param Command $command
54 *
55 * @return \DOMDocument 51 * @return \DOMDocument
56 */ 52 */
57 public function getCommandDocument(Command $command) 53 public function getCommandDocument(Command $command)
58 { 54 {
59 $dom = new \DOMDocument('1.0', 'UTF-8'); 55 $dom = new \DOMDocument('1.0', 'UTF-8');
62 $command->getSynopsis(); 58 $command->getSynopsis();
63 $command->mergeApplicationDefinition(false); 59 $command->mergeApplicationDefinition(false);
64 60
65 $commandXML->setAttribute('id', $command->getName()); 61 $commandXML->setAttribute('id', $command->getName());
66 $commandXML->setAttribute('name', $command->getName()); 62 $commandXML->setAttribute('name', $command->getName());
63 $commandXML->setAttribute('hidden', $command->isHidden() ? 1 : 0);
67 64
68 $commandXML->appendChild($usagesXML = $dom->createElement('usages')); 65 $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
69 66
70 foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) { 67 foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
71 $usagesXML->appendChild($dom->createElement('usage', $usage)); 68 $usagesXML->appendChild($dom->createElement('usage', $usage));
92 public function getApplicationDocument(Application $application, $namespace = null) 89 public function getApplicationDocument(Application $application, $namespace = null)
93 { 90 {
94 $dom = new \DOMDocument('1.0', 'UTF-8'); 91 $dom = new \DOMDocument('1.0', 'UTF-8');
95 $dom->appendChild($rootXml = $dom->createElement('symfony')); 92 $dom->appendChild($rootXml = $dom->createElement('symfony'));
96 93
97 if ($application->getName() !== 'UNKNOWN') { 94 if ('UNKNOWN' !== $application->getName()) {
98 $rootXml->setAttribute('name', $application->getName()); 95 $rootXml->setAttribute('name', $application->getName());
99 if ($application->getVersion() !== 'UNKNOWN') { 96 if ('UNKNOWN' !== $application->getVersion()) {
100 $rootXml->setAttribute('version', $application->getVersion()); 97 $rootXml->setAttribute('version', $application->getVersion());
101 } 98 }
102 } 99 }
103 100
104 $rootXml->appendChild($commandsXML = $dom->createElement('commands')); 101 $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
105 102
106 $description = new ApplicationDescription($application, $namespace); 103 $description = new ApplicationDescription($application, $namespace, true);
107 104
108 if ($namespace) { 105 if ($namespace) {
109 $commandsXML->setAttribute('namespace', $namespace); 106 $commandsXML->setAttribute('namespace', $namespace);
110 } 107 }
111 108
170 $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null)); 167 $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
171 } 168 }
172 169
173 /** 170 /**
174 * Appends document children to parent node. 171 * Appends document children to parent node.
175 *
176 * @param \DOMNode $parentNode
177 * @param \DOMNode $importedParent
178 */ 172 */
179 private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent) 173 private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
180 { 174 {
181 foreach ($importedParent->childNodes as $childNode) { 175 foreach ($importedParent->childNodes as $childNode) {
182 $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true)); 176 $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
184 } 178 }
185 179
186 /** 180 /**
187 * Writes DOM document. 181 * Writes DOM document.
188 * 182 *
189 * @param \DOMDocument $dom
190 *
191 * @return \DOMDocument|string 183 * @return \DOMDocument|string
192 */ 184 */
193 private function writeDocument(\DOMDocument $dom) 185 private function writeDocument(\DOMDocument $dom)
194 { 186 {
195 $dom->formatOutput = true; 187 $dom->formatOutput = true;
196 $this->write($dom->saveXML()); 188 $this->write($dom->saveXML());
197 } 189 }
198 190
199 /** 191 /**
200 * @param InputArgument $argument
201 *
202 * @return \DOMDocument 192 * @return \DOMDocument
203 */ 193 */
204 private function getInputArgumentDocument(InputArgument $argument) 194 private function getInputArgumentDocument(InputArgument $argument)
205 { 195 {
206 $dom = new \DOMDocument('1.0', 'UTF-8'); 196 $dom = new \DOMDocument('1.0', 'UTF-8');
221 211
222 return $dom; 212 return $dom;
223 } 213 }
224 214
225 /** 215 /**
226 * @param InputOption $option
227 *
228 * @return \DOMDocument 216 * @return \DOMDocument
229 */ 217 */
230 private function getInputOptionDocument(InputOption $option) 218 private function getInputOptionDocument(InputOption $option)
231 { 219 {
232 $dom = new \DOMDocument('1.0', 'UTF-8'); 220 $dom = new \DOMDocument('1.0', 'UTF-8');