Skip to content

Remove dash prefix from route name #7027

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

Merged
merged 1 commit into from
Oct 6, 2016
Merged
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
18 changes: 9 additions & 9 deletions templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ the routing configuration. Later, if you want to modify the URL of a particular
page, all you'll need to do is change the routing configuration; the templates
will automatically generate the new URL.

First, link to the "_welcome" page, which is accessible via the following routing
First, link to the "welcome" page, which is accessible via the following routing
configuration:

.. configuration-block::
Expand All @@ -593,7 +593,7 @@ configuration:
class WelcomeController extends Controller
{
/**
* @Route("/", name="_welcome")
* @Route("/", name="welcome")
*/
public function indexAction()
{
Expand All @@ -604,7 +604,7 @@ configuration:
.. code-block:: yaml

# app/config/routing.yml
_welcome:
welcome:
path: /
defaults: { _controller: AppBundle:Welcome:index }

Expand All @@ -617,7 +617,7 @@ configuration:
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="_welcome" path="/">
<route id="welcome" path="/">
<default key="_controller">AppBundle:Welcome:index</default>
</route>
</routes>
Expand All @@ -629,7 +629,7 @@ configuration:
use Symfony\Component\Routing\RouteCollection;

$collection = new RouteCollection();
$collection->add('_welcome', new Route('/', array(
$collection->add('welcome', new Route('/', array(
'_controller' => 'AppBundle:Welcome:index',
)));

Expand All @@ -641,11 +641,11 @@ To link to the page, just use the ``path`` Twig function and refer to the route:

.. code-block:: html+twig

<a href="{{ path('_welcome') }}">Home</a>
<a href="{{ path('welcome') }}">Home</a>

.. code-block:: html+php

<a href="<?php echo $view['router']->generate('_welcome') ?>">Home</a>
<a href="<?php echo $view['router']->generate('welcome') ?>">Home</a>

As expected, this will generate the URL ``/``. Now, for a more complicated
route:
Expand Down Expand Up @@ -737,7 +737,7 @@ correctly:

.. code-block:: html+twig

<a href="{{ url('_welcome') }}">Home</a>
<a href="{{ url('welcome') }}">Home</a>

The same can be done in PHP templates by passing a third argument to
the ``generate()`` method:
Expand All @@ -749,7 +749,7 @@ correctly:
?>

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