function YamlFileLoader::parseImport
Parses an import and adds the routes in the resource to the RouteCollection.
1 call to YamlFileLoader::parseImport()
- YamlFileLoader::load in vendor/
symfony/ routing/ Loader/ YamlFileLoader.php
File
-
vendor/
symfony/ routing/ Loader/ YamlFileLoader.php, line 174
Class
- YamlFileLoader
- YamlFileLoader loads Yaml routing files.
Namespace
Symfony\Component\Routing\LoaderCode
protected function parseImport(RouteCollection $collection, array $config, string $path, string $file) : void {
$type = $config['type'] ?? null;
$prefix = $config['prefix'] ?? '';
$defaults = $config['defaults'] ?? [];
$requirements = $config['requirements'] ?? [];
$options = $config['options'] ?? [];
$host = $config['host'] ?? null;
$condition = $config['condition'] ?? null;
$schemes = $config['schemes'] ?? null;
$methods = $config['methods'] ?? null;
$trailingSlashOnRoot = $config['trailing_slash_on_root'] ?? true;
$namePrefix = $config['name_prefix'] ?? null;
$exclude = $config['exclude'] ?? null;
if (isset($config['controller'])) {
$defaults['_controller'] = $config['controller'];
}
if (isset($config['locale'])) {
$defaults['_locale'] = $config['locale'];
}
if (isset($config['format'])) {
$defaults['_format'] = $config['format'];
}
if (isset($config['utf8'])) {
$options['utf8'] = $config['utf8'];
}
if (isset($config['stateless'])) {
$defaults['_stateless'] = $config['stateless'];
}
$this->setCurrentDir(\dirname($path));
/** @var RouteCollection[] $imported */
$imported = $this->import($config['resource'], $type, false, $file, $exclude) ?: [];
if (!\is_array($imported)) {
$imported = [
$imported,
];
}
foreach ($imported as $subCollection) {
$this->addPrefix($subCollection, $prefix, $trailingSlashOnRoot);
if (null !== $host) {
$this->addHost($subCollection, $host);
}
if (null !== $condition) {
$subCollection->setCondition($condition);
}
if (null !== $schemes) {
$subCollection->setSchemes($schemes);
}
if (null !== $methods) {
$subCollection->setMethods($methods);
}
if (null !== $namePrefix) {
$subCollection->addNamePrefix($namePrefix);
}
$subCollection->addDefaults($defaults);
$subCollection->addRequirements($requirements);
$subCollection->addOptions($options);
$collection->addCollection($subCollection);
}
}