Skip to content
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

[Routing][3.0] change constant values of UrlGeneratorInterface #14672

Closed
Tobion opened this issue May 17, 2015 · 2 comments
Closed

[Routing][3.0] change constant values of UrlGeneratorInterface #14672

Tobion opened this issue May 17, 2015 · 2 comments
Labels

Comments

@Tobion
Copy link
Member

Tobion commented May 17, 2015

Currently the UrlGeneratorInterface has @param bool|string $referenceType The type of reference to be generated (one of the constants). So a type bool|string for historic BC reasons which is bad especially considering possible future scalar type hints.

So we should change the values of the constants (probably to int) in symfony 3.0. In PHP code, people should be using the constants for calling code anyway. And for twig, there are helpers (url and path which both have a relative boolean parameter. So they are not influenced. The main change would be for PHP templates using the RouterHelper. Currently even the symfony documentation doesn't use constants (which would suck in templates), but the real values: http://symfony.com/doc/current/book/templating.html#linking-to-pages

So if we keep PHP templates in symfony (ref. #12897), we should IMO also deprecate the generate method of the helper and instead add path and url methods to the helper. This way php templates would be closer to twig equivalents and people would not be forced into using constants (or meaningless numeric values) in templates.

@jakzal jakzal added the Routing label May 17, 2015
@xabbuh xabbuh added this to the 3.0 milestone May 19, 2015
@Tobion
Copy link
Member Author

Tobion commented Sep 13, 2015

Considering constant values will not be part of the BC promise, we can even do this in 2.x. Ref. symfony/symfony-docs#5672

@fabpot
Copy link
Member

fabpot commented Sep 13, 2015

I agree.

fabpot added a commit that referenced this issue Oct 19, 2015
…hp templates consistent with twig (Tobion)

This PR was merged into the 2.8 branch.

Discussion
----------

Unify URL generator reference type + make linking in php templates consistent with twig

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #14672
| License       | MIT
| Doc PR        | TODO

Please see ticket.
Please merge #16277 first. I will then rebase this to make tests pass.

Commits
-------

388fa43 [Templating] deprecate low-level RouterHelper::generate method as it's cumbersome to use constants in templates
97d6828 [Templating] introduce path and url methods in php templates to be in line with twig templates
912fc4d [Routing] deprecate the old url generator reference type values
@fabpot fabpot closed this as completed Oct 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants