8000 Clarify that route defaults don't need a placeholder by iamdto · Pull Request #4017 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 1 commit into from
Sep 22, 2014
Merged

Clarify that route defaults don't need a placeholder #4017

merged 1 commit into from
Sep 22, 2014

Conversation

iamdto
Copy link
Contributor
@iamdto iamdto commented Jul 11, 2014
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>
Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see symfony/symfony#11394

@iamdto Did you open an issue which should be referenced there? I didn't find one.

Copy link
Contributor Author

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?

Copy link
Member

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).

Copy link
Contributor Author

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).

Copy link
Member

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.

xabbuh added a commit to xabbuh/symfony that referenced this pull request Jul 15, 2014
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not
capable of defining array default values.
@iamdto iamdto changed the title [WIP] Clarify that route defaults don't need a placeholder Clarify that route defaults don't need a placeholder Jul 16, 2014
@iamdto
Copy link
Contributor Author
iamdto commented Jul 16, 2014

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 name parameter to title. It makes more sense as the example is talking about a blog.

Should be good to merge now.

xabbuh added a commit to xabbuh/symfony that referenced this pull request Jul 18, 2014
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not
capable of defining array default values.
xabbuh added a commit to xabbuh/symfony that referenced this pull request Jul 18, 2014
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not
capable of defining array default values.
xabbuh added a commit to xabbuh/symfony that referenced this pull request Jul 18, 2014
As pointed out in symfony/symfony-docs#4017, the XmlFileLoader was not
capable of defining array default values.
xabbuh added a commit to xabbuh/symfony that referenced this pull request Jul 18, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Jul 19, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Jul 19, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Jul 19, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Jul 19, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Jul 19, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Jul 19, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Jul 20, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Jul 20, 2014
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::
Copy link
Member

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?

Copy link
Member

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!

Copy link
Contributor Author

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!

Copy link
Member

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 :).

xabbuh added a commit to xabbuh/symfony that referenced this pull request Jul 25, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Aug 12, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Aug 12, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Aug 14, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Aug 14, 2014
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 added a commit to xabbuh/symfony that referenced this pull request Aug 14, 2014
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.
@wouterj
Copy link
Member
wouterj commented Aug 15, 2014

ping @iamdto, it would be nice to get this merged!

@iamdto
Copy link
Contributor Author
iamdto commented Aug 18, 2014

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.

@weaverryan
Copy link
Member

No worries :). Yes, a new cookbook entry then we'll have another look.

Thanks!

@iamdto
Copy link
Contributor Author
iamdto commented Sep 9, 2014

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:
Copy link
Member

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 :).

@weaverryan
Copy link
Member

@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
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

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. :)

@iamdto
Copy link
Contributor Author
iamdto commented Sep 16, 2014

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] route path, but you [...]

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamdto With the current wording I would add the comma as @wouterj suggested. There has been and "and" and not a "but" before, hasn't it?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Sorry for the confusion.

@wouterj
Copy link
Member
wouterj commented Sep 16, 2014

@iamdto I've found one very minor thing, apart from that it's finished imo

@iamdto
Copy link
Contributor Author
iamdto commented Sep 22, 2014

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

information

@iamdto
Copy link
Contributor Author
iamdto commented Sep 22, 2014

Updated.

Sidenote about GitHub: are you notified when commits are added or updated?

@xabbuh
Copy link
Member
xabbuh commented Sep 22, 2014

@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! 👍

@weaverryan
Copy link
Member

I love it! Thanks Denis!

@weaverryan weaverryan merged commit a18e5cc into symfony:2.3 Sep 22, 2014
weaverryan added a commit that referenced this pull request Sep 22, 2014
…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
xabbuh added a commit to xabbuh/symfony that referenced this pull request Jun 23, 2016
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 added a commit to xabbuh/symfony that referenced this pull request Jun 23, 2016
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.
fabpot added a commit to symfony/symfony that referenced this pull request Jun 23, 2016
…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
symfony-splitter pushed a commit to symfony/routing that referenced this pull request Jun 23, 2016
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0