-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Conversation
… options without adding a prefix at all. so RouteCollection::addPrefix('', array('default' => 'value')) was used in addCollection() to add defaults to child routes, but not adding a prefix. this was just a hack. instead RouteCollection now offers a dedicated method to add such configs.
it has been deprecated because adding options has nothing to do with adding a path prefix
these prefix, defaults, requirements params were redundant to the behavior of addPrefix. and with the addition of hostnamePattern, this method did basically everything although there are already specific methods for these use-cases. the single responsibility of the methods provides a better API
… than array anyway
…nt with addPrefix which also accepts placeholders with defaults and requirements
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.
@fabpot this is finished and rebased. I switched from |
|
||
$matcher = new UrlMatcher($coll, new RequestContext()); | ||
$this->assertEquals(array('_route' => 'bar'), $matcher->match('/new')); | ||
} | ||
public function testWithHostname() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing empty line
Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))` | ||
After: | ||
``` | ||
$collection->addPrefix('/prefix', array(...), array(...)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using the new methods instead of the deprecated one here (where you pass additional arguments to addCollection)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. addPrefix('/prefix', array(...), array(...));
with defaults and requirements is not deprecated.
This PR was merged into the master branch. Commits ------- 237bbd0 fixed and refactored YamlFileLoader in the same sense as the XmlFileLoader 392d785 removed covers annotation from loader tests and unneeded use statements 45987eb added tests for the previous XmlFileLoader fixes b20d6a7 ensure id, pattern and resource are specified 8361b5a refactor the XMlFileLoader 83fc5ff fix namespace handling in xml loader; it could not handle prefixes 1a60a3c make resource and key attributes required in xsd 02e01b9 improve exception messages in xml loader 51fbffe remove unneeded cast 358e9c4 fix some phpdoc Discussion ---------- [Routing] improve loaders BC break: no Main points: - fixed Xml loader that could not handle namespace prefixes but is valid xml - fixed Yaml loader where some nonsesense configs were not validated correctly like an imported resource with a pattern key. Added tests for all. Some refactoring + a few tweaks like better exception messages and more consistency between Xml loader and yaml loader. See also commits. --------------------------------------------------------------------------- by Tobion at 2012-12-07T18:16:08Z @fabpot this is ready --------------------------------------------------------------------------- by Tobion at 2012-12-11T17:30:10Z @fabpot rebased. Please don't squash to one big commit where one does not see what changed why. --------------------------------------------------------------------------- by fabpot at 2012-12-11T17:32:40Z I only squash when most commits are CS fixes and feedback. --------------------------------------------------------------------------- by Tobion at 2012-12-11T17:37:49Z Well, you squashed #6022 so it's not possible to revert a specific deprecation.
BC break: only the internal behavior of addPrefix()
Deprecations:
and it's also useless since we dont have a tree anymore)
Reasoning see commits and changelog.