Skip to content

Modify default routing parameter on indexAction #401

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

hanahiroAze
Copy link

I found $page parameter's type on default routing is different from that of "/page/{page}" routing.
This difference seems not to be reasonable, then I fix it.

@xabbuh
Copy link
Member

xabbuh commented Nov 12, 2016

I don't understand what you mean. Which other default value are you talking about?

@hanahiroAze
Copy link
Author

hanahiroAze commented Nov 13, 2016

In @Route("/", defaults={"page": 1}, name="blog_index"), the parameter "page" is set as int value by {"page": 1}, but in @Route("/page/{page}", requirements={"page": "[1-9]\d*"}, name="blog_index_paginated") the parameter "page" is set as string value by {"page": "[1-9]\d*"}.

When I dump $page parameter in BlogController.indecAction(), Symfony profiler says like below and I found the parameter's type is different.

  • Top page -> application
    2016-11-12 19 21 32
  • click "Next" button
    2016-11-12 19 22 58
  • click "Previous" button
    2016-11-13 15 03 08

@bocharsky-bw
Copy link
Contributor

I think it makes sense for PHP 7 scalar types hinting 👍

@javiereguiluz
Copy link
Member

javiereguiluz commented Nov 18, 2016

I'm merging this because I think it makes sense to treat this routing parameter consistently. Thanks @hanahiroAze

@javiereguiluz javiereguiluz merged commit 1cc1f9c into symfony:master Nov 18, 2016
javiereguiluz added a commit that referenced this pull request Nov 18, 2016
This PR was merged into the master branch.

Discussion
----------

Modify default routing parameter on indexAction

I found $page parameter's type on default routing is different from that of "/page/{page}" routing.
This difference seems not to be reasonable, then I fix it.

Commits
-------

1cc1f9c modify default param page's type for / on BlogController to be same as that of "/page/{page}"
@hanahiroAze hanahiroAze deleted the modify_default_routing_param_on_indexAction branch November 30, 2022 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants