Skip to content

Commit

Permalink
[Components][Routing] Fix addPrefix() sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
bicpi committed Mar 11, 2014
1 parent fc0aa8b commit e095c13
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
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

0 comments on commit e095c13

Please sign in to comment.