Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/routing/Loader/YamlFileLoader.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 |
line wrap: on
line diff
--- a/vendor/symfony/routing/Loader/YamlFileLoader.php Tue Jul 10 15:07:59 2018 +0100 +++ b/vendor/symfony/routing/Loader/YamlFileLoader.php Thu Feb 28 13:21:36 2019 +0000 @@ -11,12 +11,12 @@ namespace Symfony\Component\Routing\Loader; +use Symfony\Component\Config\Loader\FileLoader; +use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Parser as YamlParser; -use Symfony\Component\Config\Loader\FileLoader; /** * YamlFileLoader loads Yaml routing files. @@ -26,9 +26,9 @@ */ class YamlFileLoader extends FileLoader { - private static $availableKeys = array( + private static $availableKeys = [ 'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller', - ); + ]; private $yamlParser; /** @@ -80,7 +80,7 @@ } // not an array - if (!is_array($parsedConfig)) { + if (!\is_array($parsedConfig)) { throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path)); } @@ -102,7 +102,7 @@ */ public function supports($resource, $type = null) { - return is_string($resource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true) && (!$type || 'yaml' === $type); + return \is_string($resource) && \in_array(pathinfo($resource, PATHINFO_EXTENSION), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type); } /** @@ -115,12 +115,12 @@ */ protected function parseRoute(RouteCollection $collection, $name, array $config, $path) { - $defaults = isset($config['defaults']) ? $config['defaults'] : array(); - $requirements = isset($config['requirements']) ? $config['requirements'] : array(); - $options = isset($config['options']) ? $config['options'] : array(); + $defaults = isset($config['defaults']) ? $config['defaults'] : []; + $requirements = isset($config['requirements']) ? $config['requirements'] : []; + $options = isset($config['options']) ? $config['options'] : []; $host = isset($config['host']) ? $config['host'] : ''; - $schemes = isset($config['schemes']) ? $config['schemes'] : array(); - $methods = isset($config['methods']) ? $config['methods'] : array(); + $schemes = isset($config['schemes']) ? $config['schemes'] : []; + $methods = isset($config['methods']) ? $config['methods'] : []; $condition = isset($config['condition']) ? $config['condition'] : null; if (isset($config['controller'])) { @@ -144,9 +144,9 @@ { $type = isset($config['type']) ? $config['type'] : null; $prefix = isset($config['prefix']) ? $config['prefix'] : ''; - $defaults = isset($config['defaults']) ? $config['defaults'] : array(); - $requirements = isset($config['requirements']) ? $config['requirements'] : array(); - $options = isset($config['options']) ? $config['options'] : array(); + $defaults = isset($config['defaults']) ? $config['defaults'] : []; + $requirements = isset($config['requirements']) ? $config['requirements'] : []; + $options = isset($config['options']) ? $config['options'] : []; $host = isset($config['host']) ? $config['host'] : null; $condition = isset($config['condition']) ? $config['condition'] : null; $schemes = isset($config['schemes']) ? $config['schemes'] : null; @@ -156,12 +156,12 @@ $defaults['_controller'] = $config['controller']; } - $this->setCurrentDir(dirname($path)); + $this->setCurrentDir(\dirname($path)); $imported = $this->import($config['resource'], $type, false, $file); - if (!is_array($imported)) { - $imported = array($imported); + if (!\is_array($imported)) { + $imported = [$imported]; } foreach ($imported as $subCollection) { @@ -199,32 +199,20 @@ */ protected function validate($config, $name, $path) { - if (!is_array($config)) { + if (!\is_array($config)) { throw new \InvalidArgumentException(sprintf('The definition of "%s" in "%s" must be a YAML array.', $name, $path)); } if ($extraKeys = array_diff(array_keys($config), self::$availableKeys)) { - throw new \InvalidArgumentException(sprintf( - 'The routing file "%s" contains unsupported keys for "%s": "%s". Expected one of: "%s".', - $path, $name, implode('", "', $extraKeys), implode('", "', self::$availableKeys) - )); + throw new \InvalidArgumentException(sprintf('The routing file "%s" contains unsupported keys for "%s": "%s". Expected one of: "%s".', $path, $name, implode('", "', $extraKeys), implode('", "', self::$availableKeys))); } if (isset($config['resource']) && isset($config['path'])) { - throw new \InvalidArgumentException(sprintf( - 'The routing file "%s" must not specify both the "resource" key and the "path" key for "%s". Choose between an import and a route definition.', - $path, $name - )); + throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "resource" key and the "path" key for "%s". Choose between an import and a route definition.', $path, $name)); } if (!isset($config['resource']) && isset($config['type'])) { - throw new \InvalidArgumentException(sprintf( - 'The "type" key for the route definition "%s" in "%s" is unsupported. It is only available for imports in combination with the "resource" key.', - $name, $path - )); + throw new \InvalidArgumentException(sprintf('The "type" key for the route definition "%s" in "%s" is unsupported. It is only available for imports in combination with the "resource" key.', $name, $path)); } if (!isset($config['resource']) && !isset($config['path'])) { - throw new \InvalidArgumentException(sprintf( - 'You must define a "path" for the route "%s" in file "%s".', - $name, $path - )); + throw new \InvalidArgumentException(sprintf('You must define a "path" for the route "%s" in file "%s".', $name, $path)); } if (isset($config['controller']) && isset($config['defaults']['_controller'])) { throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "controller" key and the defaults key "_controller" for "%s".', $path, $name));