namespace Symfony\Component\Routing\Loader;
-use Symfony\Component\Routing\RouteCollection;
-use Symfony\Component\Routing\Route;
+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\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser as YamlParser;
-use Symfony\Component\Config\Loader\FileLoader;
/**
* YamlFileLoader loads Yaml routing files.
}
// not an array
- if (!is_array($parsedConfig)) {
+ if (!\is_array($parsedConfig)) {
throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path));
}
*/
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), array('yml', 'yaml'), true) && (!$type || 'yaml' === $type);
}
/**
$defaults['_controller'] = $config['controller'];
}
- $this->setCurrentDir(dirname($path));
+ $this->setCurrentDir(\dirname($path));
$imported = $this->import($config['resource'], $type, false, $file);
- if (!is_array($imported)) {
+ if (!\is_array($imported)) {
$imported = array($imported);
}
*/
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));