@@ -709,8 +709,11 @@ tags:
709
709
array('renderer' => 'hinclude')
710
710
) ?>
711
711
712
+ <!-- The url() method was introduced in Symfony 2.8. Prior to 2.8, you
713
+ had to use generate() with UrlGeneratorInterface::ABSOLUTE_URL
714
+ passed as third argument. -->
712
715
<?php echo $view['actions']->render(
713
- $view['router']->generate ('...'),
716
+ $view['router']->url ('...'),
714
717
array('renderer' => 'hinclude')
715
718
) ?>
716
719
@@ -918,7 +921,9 @@ To link to the page, just use the ``path`` Twig function and refer to the route:
918
921
919
922
.. code-block :: html+php
920
923
921
- <a href="<?php echo $view['router']->generate('_welcome') ?>">Home</a>
924
+ <!-- The path() method was introduced in Symfony 2.8. Prior to 2.8, you
925
+ had to use generate(). -->
926
+ <a href="<?php echo $view['router']->path('_welcome') ?>">Home</a>
922
927
923
928
As expected, this will generate the URL ``/ ``. Now, for a more complicated
924
929
route:
@@ -997,7 +1002,9 @@ correctly:
997
1002
998
1003
<!-- app/Resources/views/Article/recent_list.html.php -->
999
1004
<?php foreach ($articles in $article): ?>
1000
- <a href="<?php echo $view['router']->generate('article_show', array(
1005
+ <!-- The path() method was introduced in Symfony 2.8. Prior to 2.8,
1006
+ you had to use generate(). -->
1007
+ <a href="<?php echo $view['router']->path('article_show', array(
1001
1008
'slug' => $article->getSlug(),
1002
1009
)) ?>">
1003
1010
<?php echo $article->getTitle() ?>
@@ -1006,26 +1013,26 @@ correctly:
1006
1013
1007
1014
.. tip ::
1008
1015
1009
- You can also generate an absolute URL by using the ``url `` Twig function:
1016
+ You can also generate an absolute URL by using the ``url `` function:
1010
1017
1011
- .. code -block :: html+twig
1018
+ .. configuration -block ::
1012
1019
1013
- <a href="{{ url('_welcome') }}">Home</a>
1020
+ .. code-block :: html+twig
1014
1021
1015
- The same can be done in PHP templates by passing a third argument to
1016
- the ``generate() `` method:
1022
+ <a href="{{ url('_welcome') }}">Home</a>
1017
1023
1018
- .. code-block :: html+php
1024
+ .. code-block :: html+php
1019
1025
1020
- <?php
1021
- use Symfony\C omponent\R outing\G enerator\U rlGeneratorInterface;
1022
- ?>
1026
+ <a href="<?php echo $view['router']->url(
1027
+ '_welcome',
1028
+ array()
1029
+ ) ?>">Home</a>
1023
1030
1024
- <a href="<?php echo $view['router']->generate(
1025
- '_welcome',
1026
- array(),
1027
- UrlGeneratorInterface::ABSOLUTE_URL
1028
- ) ?>">Home</a>
1031
+ .. versionadded :: 2.8
1032
+ The `` url() `` PHP templating helper was introduced in Symfony 2.8. Prior
1033
+ to 2.8, you had to use the `` generate() `` helper method with
1034
+ `` Symfony\Component\Routing\Generator\ UrlGeneratorInterface::ABSOLUTE_URL``
1035
+ passed as third argument.
1029
1036
1030
1037
.. index ::
1031
1038
single: Templating; Linking to assets
@@ -1696,7 +1703,9 @@ key in the parameter hash:
1696
1703
1697
1704
.. code-block :: html+php
1698
1705
1699
- <a href="<?php echo $view['router']->generate('article_show', array(
1706
+ <!-- The path() method was introduced in Symfony 2.8. Prior to 2.8, you
1707
+ had to use generate(). -->
1708
+ <a href="<?php echo $view['router']->path('article_show', array(
1700
1709
'id' => 123,
1701
1710
'_format' => 'pdf',
1702
1711
)) ?>">
0 commit comments