You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
…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
Currently the UrlGeneratorInterface has
@param bool|string $referenceType The type of reference to be generated (one of the constants)
. So a typebool|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
andpath
which both have arelative
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-pagesSo if we keep PHP templates in symfony (ref. #12897), we should IMO also deprecate the
generate
method of the helper and instead addpath
andurl
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.The text was updated successfully, but these errors were encountered: