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

use constants to choose generated URL type #5813

Merged
merged 1 commit into from
Nov 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion book/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1499,9 +1499,13 @@ to ``generate()``:

.. code-block:: html+php

<?php
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
?>

<a href="<?php echo $view['router']->generate('blog_show', array(
'slug' => 'my-blog-post',
), true) ?>">
), UrlGeneratorInterface::ABSOLUTE_URL) ?>">
Read this blog post.
</a>

Expand Down
6 changes: 5 additions & 1 deletion book/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -992,10 +992,14 @@ correctly:

.. code-block:: html+php

<?php
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
?>

<a href="<?php echo $view['router']->generate(
'_welcome',
array(),
true
UrlGeneratorInterface::ABSOLUTE_URL
) ?>">Home</a>

.. index::
Expand Down
7 changes: 6 additions & 1 deletion cookbook/controller/service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,12 @@ controller:
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::generateUrl` (service: ``router``)
.. code-block:: php

$router->generate($route, $params, $absolute);
$router->generate($route, $params, $referenceType);

.. note::

The ``$referenceType`` argument must be one of the constants defined
in the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface`.

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

Expand Down
6 changes: 5 additions & 1 deletion cookbook/templating/render_without_controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ this is probably only useful if you'd like to cache this page partial (see

.. code-block:: html+php

<?php
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
?>

<?php echo $view['actions']->render(
$view['router']->generate('acme_privacy', array(), true)
$view['router']->generate('acme_privacy', array(), UrlGeneratorInterface::ABSOLUTE_URL)
) ?>

.. _cookbook-templating-no-controller-caching:
Expand Down
8 changes: 7 additions & 1 deletion create_framework/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,13 @@ impact. Want to know how to use the generator? Insanely easy::
The code should be self-explanatory; and thanks to the context, you can even
generate absolute URLs::

echo $generator->generate('hello', array('name' => 'Fabien'), true);
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

echo $generator->generate(
'hello',
array('name' => 'Fabien'),
UrlGeneratorInterface::ABSOLUTE_URL
);
// outputs something like http://example.com/somewhere/hello/Fabien

.. tip::
Expand Down