Skip to content

[Components][Routing] Fix addPrefix() sample code #3622

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
Mar 12, 2014
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
4 changes: 2 additions & 2 deletions book/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The route is simple:
return $collection;

.. versionadded:: 2.2
The ``path`` option is new in Symfony2.2, ``pattern`` is used in older
The ``path`` option is new in Symfony 2.2, ``pattern`` is used in older
versions.

The path defined by the ``blog_show`` route acts like ``/blog/*`` where
Expand Down Expand Up @@ -704,7 +704,7 @@ be accomplished with the following route configuration:
return $collection;

.. versionadded:: 2.2
The ``methods`` option is added in Symfony2.2. Use the ``_method``
The ``methods`` option is added in Symfony 2.2. Use the ``_method``
requirement in older versions.

Despite the fact that these two routes have identical paths (``/contact``),
Expand Down
28 changes: 14 additions & 14 deletions components/routing/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,26 @@ Using Prefixes

You can add routes or other instances of
:class:`Symfony\\Component\\Routing\\RouteCollection` to *another* collection.
This way you can build a tree of routes. Additionally you can define a prefix,
default requirements, default options and host to all routes of a subtree with
the :method:`Symfony\\Component\\Routing\\RouteCollection::addPrefix` method::
This way you can build a tree of routes. Additionally you can define a prefix
and default values for the parameters, requirements, options, schemes and the
host to all routes of a subtree using methods provided by the
``RouteCollection`` class::

$rootCollection = new RouteCollection();

$subCollection = new RouteCollection();
$subCollection->add(...);
$subCollection->add(...);
$subCollection->addPrefix(
'/prefix', // prefix
array(), // requirements
array(), // options
'admin.example.com', // host
array('https') // schemes
);
$subCollection->addPrefix('/prefix');
$subCollection->addDefaults(array(...));
$subCollection->addRequirements(array(...));
$subCollection->addOptions(array(...));
$subCollection->setHost('admin.example.com');
$subCollection->setMethods(array('POST'));
$subCollection->setSchemes(array('https'));

$rootCollection->addCollection($subCollection);

.. versionadded:: 2.2
The ``addPrefix`` method is added in Symfony2.2. This was part of the
``addCollection`` method in older versions.

Set the Request Parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -177,7 +175,9 @@ with this class via its constructor::
$host = 'localhost',
$scheme = 'http',
$httpPort = 80,
$httpsPort = 443
$httpsPort = 443,
$path = '/',
$queryString = ''
)

.. _components-routing-http-foundation:
Expand Down