Skip to content

Commit f00efff

Browse files
committed
use constants to choose generated URL type
1 parent 71469ff commit f00efff

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
@@ -992,10 +992,14 @@ correctly:
992992

993993
.. code-block:: html+php
994994

995+
<?php
996+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
997+
?>
998+
995999
<a href="<?php echo $view['router']->generate(
9961000
'_welcome',
9971001
array(),
998-
true
1002+
UrlGeneratorInterface::ABSOLUTE_URL
9991003
) ?>">Home</a>
10001004

10011005
.. 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy