8000 [Routing] clean up of RouteCollection API by Tobion · Pull Request #6022 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing] clean up of RouteCollection API #6022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix the loaders to not use the deprecated API
it also fixes the xml and yaml loader that was not using the empty hostname pattern when importing a resource to reset the hostname pattern for it.
  • Loading branch information
Tobion committed Dec 6, 2012
commit b6d1e221e7c3a6ed4594fa88380122b8ea1abb07
12 changes: 10 additions & 2 deletions src/Symfony/Component/Routing/Loader/XmlFileLoader.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, $pa
$resource = $node->getAttribute('resource');
$type = $node->getAttribute('type');
$prefix = $node->getAttribute('prefix');
$hostnamePattern = $node->getAttribute('hostname-pattern');
$hostnamePattern = $node->hasAttribute('hostname-pattern') ? $node->getAttribute('hostname-pattern') : null;

$defaults = array();
$requirements = array();
Expand All @@ -105,7 +105,15 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, $pa
}

$this->setCurrentDir(dirname($path));
$collection->addCollection($this->import($resource, ('' !== $type ? $type : null), false, $file), $prefix, $defaults, $requirements, $options, $hostnamePattern);

$subCollection = $this->import($resource, ('' !== $type ? $type : null), false, $file);
/* @var RouteCollection $subCollection */
$subCollection->addPrefix($prefix);
if (null !== $hostnamePattern) {
$subCollection->setHostnamePattern($hostnamePattern);
}
$subCollection->addConfigs($defaults, $requirements, $options);
$collection->addCollection($subCollection);
break;
default:
throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $node->tagName));
Expand Down
14 changes: 11 additions & 3 deletions src/Symfony/Component/Routing/Loader/YamlFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,22 @@ public function load($file, $type = null)

if (isset($config['resource'])) {
$type = isset($config['type']) ? $config['type'] : null;
$prefix = isset($config['prefix']) ? $config['prefix'] : 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();
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : '';
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : null;

$this->setCurrentDir(dirname($path));
$collection->addCollection($this->import($config['resource'], $type, false, $file), $prefix, $defaults, $requirements, $options, $hostnamePattern);

$subCollection = $this->import($config['resource'], $type, false, $file);
/* @var RouteCollection $subCollection */
$subCollection->addPrefix($prefix);
if (null !== $hostnamePattern) {
$subCollection->setHostnamePattern($hostnamePattern);
}
$subCollection->addConfigs($defaults, $requirements, $options);
$collection->addCollection($subCollection);
} else {
$this->parseRoute($collection, $name, $config, $path);
}
Expand Down
0