-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Clarify that route defaults don't need a placeholder #4017
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
Q | A |
---|---|
Doc fix? | yes |
New docs? | no |
Applies to | 2.3+ |
Fixed tickets | #3960 |
<default key="_controller">AcmeBlogBundle:Blog:index</default> | ||
<default key="page">1</default> | ||
<default key="name">Ryan</default> | ||
<default key="foo"></default> |
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'm just missing the array parameter inside the XML config. If someone could help me.
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.
Looking at the schema definition, this doesn't seem to be possible in XML at the moment. The default
element can only contain string values.
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.
@Tobion do you have input on this? Do we want to support and advertise it or should we remove it feom the docs?
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.
Array parameters do not work in all cases. It is not supported for Apache rewrite rules (which is deprecated anyway) and, as you figured out, in XML definitions. So as long as it's not consistently working, I would not advertise it.
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.
But if we add XML support for it (using the same mechanism as used by DI), you think it would be a good idea?
Tbh, I'm not sure if I like the idea of array defaults (apart from the consistency). That's why I try to get other opinions
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.
@iamdto Did you open an issue which should be referenced there? I didn't find one.
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.
Nope, I was a bit busy.
Will your PR potentially get merged in Symfony 2.3 or 2.6?
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 think that it is a new feature. So it will go into 2.6 (or later).
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.
Then I think it's safe to remove the array example from this PR (which is based on 2.3) and then add it back based on the master branch once yours get merged (as it will be considered a new feature).
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. 10000
I agree. If it was merged in 2.3 though, we would be able to create a separate pull request on 2.3 here.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values.
So I removed references to the array defaults. This should be added back in another PR if @xabbuh PR is getting merged. I've also changed the Should be good to merge now. |
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
@@ -446,6 +446,63 @@ match, giving the ``page`` parameter a value of ``2``. Perfect. | |||
Routes with optional parameters at the end will not match on requests | |||
with a trailing slash (i.e. ``/blog/`` will not match, ``/blog`` will match). | |||
|
|||
.. tip:: |
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 think it's too early here, because we haven't talked about how wildcards map to arguments. We are talking about "defaults" here, but for a totally different purpose (making wildcards optional).
I'd like to see this as a tiny new cookbook entry called something like: "Passing extra Information from a Route to a Controller". We could add a little link to it at the bottom of the Route Parameters and Controller Arguments
section.
What do you think?
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.
Nice section, btw - thanks for taking this one :). It's cool feature - I hadn't realized we never talked about it!
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 think it's too early here, because we haven't talked about how wildcards map to arguments.
I don't fully agree with this. This is already discussed in the (previous) Controller chapter at Route Parameters as Controller Arguments and at the beginning of this chapter at Routing in Action, if that's what you mean?
But anyway I agree that this may not be the best place to put this tip (I was not sure when I wrote it). I'll write a new cookbook as you suggested.
Thanks for the feedback!
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.
Ah, you're right - I didn't see that we already explained the arguments part in "Routing in Action". So, it's not too early here. I still also like the idea of a separate cookbook entry, but I'm more open to where we put that link to it :).
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
ping @iamdto, it would be nice to get this merged! |
Sorry I was on holiday, I couldn't work on this. So basically I should move all of this in a new cookbook entry, right? I'll try to do it by the end of the week. |
No worries :). Yes, a new cookbook entry then we'll have another look. Thanks! |
I've added the new cookbook entry. If it's sounds OK, I'll squash my commits. Otherwise let me know what to change. |
Parameters inside the ``defaults`` collection don't necessarily have to | ||
match a placeholder in the route ``path``. In fact you can absolutely use | ||
this part of the route definition if you want to specify additional | ||
parameters that will then be accessible within the request attributes: |
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.
How about:
In fact, you can use the
defaults
array to specify extra parameters that will
then be accessible as arguments to your controller:
I don't think that most users really know what "request attributes" are :).
@iamdto I added some minor notes, but it looks great to me after those. Thanks for the hard work! |
.. index:: | ||
single: Routing; Extra Information | ||
|
||
How to Pass Extra Information from a Route to a Controller |
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 think "extra" is a closed-class word and show be lowercased.
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.
@weaverryan can you confirm this?
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.
extra is an adjective, and adjectives are mostly (or always) considered open class words. So I think this should be upper-cased.
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 see, I think I then did some lowercasing wrong in the past. Maybe I should do a re-check. :)
I've updated my commit, let me know if I need to change something. |
} | ||
|
||
As you can see, the ``$title`` variable was never defined inside the route path | ||
but you can still access its value from inside your controller. |
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.
[...] route path, but you [...]
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.
@xabbuh told me to remove this comma. Should I add it back?
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.
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.
Yes, that's right. I'll add it back.
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.
👍 Sorry for the confusion.
@iamdto I've found one very minor thing, apart from that it's finished imo |
Should be good now. |
@@ -955,6 +955,10 @@ see :ref:`route-parameters-controller-arguments`. | |||
You can also use a special ``$_route`` variable, which is set to the | |||
name of the route that was matched. | |||
|
|||
You can even add extra information to your route definition and access it | |||
within your controller. For more informations on this topic, |
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.
information
Updated. Sidenote about GitHub: are you notified when commits are added or updated? |
@iamdto No, you would have to write a comment to notify users who are subscribed to it. Anyway, I think it's ready to be merged now. Nice job! 👍 |
I love it! Thanks Denis! |
…amdto) This PR was merged into the 2.3 branch. Discussion ---------- Clarify that route defaults don't need a placeholder | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.3+ | Fixed tickets | #3960 Commits ------- a18e5cc Clarify that route defaults don't need a placeholder
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.
…xabbuh) This PR was merged into the 3.2-dev branch. Discussion ---------- [Routing] support for array values in route defaults | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | As pointed out in symfony/symfony-docs#4017, the ``XmlFileLoader`` was not capable of defining array default values. - [x] array values - [x] integer values - [x] float values - [x] boolean Commits ------- 120b35c [Routing] data type support for defaults
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not capable of defining array default values. Additionally, this commit adds support for handling associative arrays, boolean, integer, float and string data types.