Skip to content

Commit 4053c6e

Browse files
committed
minor #5813 use constants to choose generated URL type (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- use constants to choose generated URL type | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | symfony/symfony#16276 Commits ------- f00efff use constants to choose generated URL type
2 parents ef7061f + f00efff commit 4053c6e

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

book/routing.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,13 @@ to ``generate()``:
14991499

15001500
.. code-block:: html+php
15011501

1502+
<?php
1503+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1504+
?>
1505+
15021506
<a href="<?php echo $view['router']->generate('blog_show', array(
15031507
'slug' => 'my-blog-post',
1504-
), true) ?>">
1508+
), UrlGeneratorInterface::ABSOLUTE_URL) ?>">
15051509
Read this blog post.
15061510
</a>
15071511

book/templating.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,10 +1028,14 @@ correctly:
10281028

10291029
.. code-block:: html+php
10301030

1031+
<?php
1032+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1033+
?>
1034+
10311035
<a href="<?php echo $view['router']->generate(
10321036
'_welcome',
10331037
array(),
1034-
true
1038+
UrlGeneratorInterface::ABSOLUTE_URL
10351039
) ?>">Home</a>
10361040

10371041
.. index::

cookbook/controller/service.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,12 @@ controller:
269269
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::generateUrl` (service: ``router``)
270270
.. code-block:: php
271271
272-
$router->generate($route, $params, $absolute);
272+
$router->generate($route, $params, $referenceType);
273+
274+
.. note::
275+
276+
The ``$referenceType`` argument must be one of the constants defined
277+
in the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface`.
273278

274279
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getDoctrine` (service: ``doctrine``)
275280

cookbook/templating/render_without_controller.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ this is probably only useful if you'd like to cache this page partial (see
6868

6969
.. code-block:: html+php
7070

71+
<?php
72+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
73+
?>
74+
7175
<?php echo $view['actions']->render(
72-
$view['router']->generate('acme_privacy', array(), true)
76+
$view['router']->generate('acme_privacy', array(), UrlGeneratorInterface::ABSOLUTE_URL)
7377
) ?>
7478

7579
.. _cookbook-templating-no-controller-caching:

create_framework/routing.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,13 @@ impact. Want to know how to use the generator? Insanely easy::
208208
The code should be self-explanatory; and thanks to the context, you can even
209209
generate absolute URLs::
210210

211-
echo $generator->generate('hello', array('name' => 'Fabien'), true);
211+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
212+
213+
echo $generator->generate(
214+
'hello',
215+
array('name' => 'Fabien'),
216+
UrlGeneratorInterface::ABSOLUTE_URL
217+
);
212218
// outputs something like http://example.com/somewhere/hello/Fabien
213219

214220
.. tip::

0 commit comments

Comments
 (0)