comparison vendor/symfony/routing/Loader/XmlFileLoader.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
9 * file that was distributed with this source code. 9 * file that was distributed with this source code.
10 */ 10 */
11 11
12 namespace Symfony\Component\Routing\Loader; 12 namespace Symfony\Component\Routing\Loader;
13 13
14 use Symfony\Component\Config\Loader\FileLoader;
15 use Symfony\Component\Config\Resource\FileResource;
16 use Symfony\Component\Config\Util\XmlUtils;
17 use Symfony\Component\Routing\Route;
14 use Symfony\Component\Routing\RouteCollection; 18 use Symfony\Component\Routing\RouteCollection;
15 use Symfony\Component\Routing\Route;
16 use Symfony\Component\Config\Resource\FileResource;
17 use Symfony\Component\Config\Loader\FileLoader;
18 use Symfony\Component\Config\Util\XmlUtils;
19 19
20 /** 20 /**
21 * XmlFileLoader loads XML routing files. 21 * XmlFileLoader loads XML routing files.
22 * 22 *
23 * @author Fabien Potencier <fabien@symfony.com> 23 * @author Fabien Potencier <fabien@symfony.com>
91 /** 91 /**
92 * {@inheritdoc} 92 * {@inheritdoc}
93 */ 93 */
94 public function supports($resource, $type = null) 94 public function supports($resource, $type = null)
95 { 95 {
96 return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type); 96 return \is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type);
97 } 97 }
98 98
99 /** 99 /**
100 * Parses a route and adds it to the RouteCollection. 100 * Parses a route and adds it to the RouteCollection.
101 * 101 *
142 $schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null; 142 $schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null;
143 $methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null; 143 $methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null;
144 144
145 list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path); 145 list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path);
146 146
147 $this->setCurrentDir(dirname($path)); 147 $this->setCurrentDir(\dirname($path));
148 148
149 $imported = $this->import($resource, ('' !== $type ? $type : null), false, $file); 149 $imported = $this->import($resource, ('' !== $type ? $type : null), false, $file);
150 150
151 if (!is_array($imported)) { 151 if (!\is_array($imported)) {
152 $imported = array($imported); 152 $imported = [$imported];
153 } 153 }
154 154
155 foreach ($imported as $subCollection) { 155 foreach ($imported as $subCollection) {
156 /* @var $subCollection RouteCollection */ 156 /* @var $subCollection RouteCollection */
157 $subCollection->addPrefix($prefix); 157 $subCollection->addPrefix($prefix);
201 * 201 *
202 * @throws \InvalidArgumentException When the XML is invalid 202 * @throws \InvalidArgumentException When the XML is invalid
203 */ 203 */
204 private function parseConfigs(\DOMElement $node, $path) 204 private function parseConfigs(\DOMElement $node, $path)
205 { 205 {
206 $defaults = array(); 206 $defaults = [];
207 $requirements = array(); 207 $requirements = [];
208 $options = array(); 208 $options = [];
209 $condition = null; 209 $condition = null;
210 210
211 foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) { 211 foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
212 if ($node !== $n->parentNode) { 212 if ($node !== $n->parentNode) {
213 continue; 213 continue;
244 } 244 }
245 245
246 $defaults['_controller'] = $controller; 246 $defaults['_controller'] = $controller;
247 } 247 }
248 248
249 return array($defaults, $requirements, $options, $condition); 249 return [$defaults, $requirements, $options, $condition];
250 } 250 }
251 251
252 /** 252 /**
253 * Parses the "default" elements. 253 * Parses the "default" elements.
254 * 254 *
308 case 'float': 308 case 'float':
309 return (float) trim($node->nodeValue); 309 return (float) trim($node->nodeValue);
310 case 'string': 310 case 'string':
311 return trim($node->nodeValue); 311 return trim($node->nodeValue);
312 case 'list': 312 case 'list':
313 $list = array(); 313 $list = [];
314 314
315 foreach ($node->childNodes as $element) { 315 foreach ($node->childNodes as $element) {
316 if (!$element instanceof \DOMElement) { 316 if (!$element instanceof \DOMElement) {
317 continue; 317 continue;
318 } 318 }
324 $list[] = $this->parseDefaultNode($element, $path); 324 $list[] = $this->parseDefaultNode($element, $path);
325 } 325 }
326 326
327 return $list; 327 return $list;
328 case 'map': 328 case 'map':
329 $map = array(); 329 $map = [];
330 330
331 foreach ($node->childNodes as $element) { 331 foreach ($node->childNodes as $element) {
332 if (!$element instanceof \DOMElement) { 332 if (!$element instanceof \DOMElement) {
333 continue; 333 continue;
334 } 334 }