Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[2.2][Routing] Used static to call constant in XmlFileLoader #6449

Merged
merged 1 commit into from

5 participants

@francisbesset

It is more complicated to override XmlFileLoader if contants are called with self.
This PR replace self to static.

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot merged branch francisbesset/routing_constant_usage (PR #6449)
This PR was merged into the master branch.

Commits
-------

18daa10 [Routing] Used static to call constant in XmlFileLoader

Discussion
----------

[2.2][Routing] Used static to call constant in XmlFileLoader

It is more complicated to override XmlFileLoader if contants are called with `self`.
This PR replace `self` to `static`.

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

---------------------------------------------------------------------------

by piotrpasich at 2012-12-21T08:17:14Z

+1
c0e341c
@fabpot fabpot merged commit 18daa10 into symfony:master

1 check passed

Details default The Travis build passed
@Tobion
Collaborator

I used self on purpose. You must override this method anyway if you want to parse custom element/attributes.
This is why it only works with the symfony namespace. @francisbesset @piotrpasich What's your use case for static?

@francisbesset

Yes of course. I develop the BeSimpleI18nRoutingBundle, and I override YamlFileLoader and XmlFileLoader of Symfony Routing component.

static is needed for me for the XmlFileLoader::parseNode() because the logic is the same for my bundle and this method call protected methods.
I replaced self to static in XmlFileLoader::parseConfigs() to keep consistency of use static, but I override this method for my bundle.

@stof
Collaborator

@francisbesset the idea suggested in FOSRestBundle, using the full power of XML namespace, was to use a custom XML namespace only for your own tags instead of duplicating the Sf2 tags

@Tobion
Collaborator

@stof is right. That's what I suggested. Reinventing the tags in your own namespace does not make sense. Otherwise we would not need any namespaces. I don't see the point of this PR. @fabpot I think this should be reverted.

@fabpot
Owner

Then, what about removing those constants?

@Tobion
Collaborator

I think the constants are good, first for code claritiy, second because it exposes the namespace that the xml file loader expects so somebody can use the information to create valid xml routing files.

@fabpot
Owner

reverted

@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot Revert "merged branch francisbesset/routing_constant_usage (PR #6449)"
This reverts commit c0e341c, reversing
changes made to 35f5bca.
4892072
@francisbesset

@Tobion The XSD file is here for that.

@Tobion
Collaborator

@francisbesset I don't understand.

@gorkalaucirica gorkalaucirica referenced this pull request from a commit in gorkalaucirica/symfony
@fabpot fabpot Revert "merged branch francisbesset/routing_constant_usage (PR #6449)"
This reverts commit c0e341c, reversing
changes made to 35f5bca.
a19e517
@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot merged branch francisbesset/routing_constant_usage (PR #6449)
This PR was merged into the master branch.

Commits
-------

18daa10 [Routing] Used static to call constant in XmlFileLoader

Discussion
----------

[2.2][Routing] Used static to call constant in XmlFileLoader

It is more complicated to override XmlFileLoader if contants are called with `self`.
This PR replace `self` to `static`.

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

---------------------------------------------------------------------------

by piotrpasich at 2012-12-21T08:17:14Z

+1
fbd2389
@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot Revert "merged branch francisbesset/routing_constant_usage (PR #6449)"
This reverts commit c0e341c, reversing
changes made to 35f5bca.
620acda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/Symfony/Component/Routing/Loader/XmlFileLoader.php
View
4 src/Symfony/Component/Routing/Loader/XmlFileLoader.php
@@ -76,7 +76,7 @@ public function load($file, $type = null)
*/
protected function parseNode(RouteCollection $collection, \DOMElement $node, $path, $file)
{
- if (self::NAMESPACE_URI !== $node->namespaceURI) {
+ if (static::NAMESPACE_URI !== $node->namespaceURI) {
return;
}
@@ -192,7 +192,7 @@ private function parseConfigs(\DOMElement $node, $path)
$requirements = array();
$options = array();
- foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
+ foreach ($node->getElementsByTagNameNS(static::NAMESPACE_URI, '*') as $n) {
switch ($n->localName) {
case 'default':
$defaults[$n->getAttribute('key')] = trim($n->textContent);
Something went wrong with that request. Please try again.