Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added use of addPrefix to define prefixes
  • Loading branch information
wouterj committed Jan 21, 2013
commit 38e8dad6bcc86a5f6bb88dac7d6cc9ea0d7d9461
14 changes: 10 additions & 4 deletions components/routing/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,29 @@ 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 hostname to all routes of a subtree::
default requirements, default options and hostname to all routes of a subtree
with the :method:`Symfony\\Component\\Routing\\RouteCollection::addPrefix`
method::

$rootCollection = new RouteCollection();

$subCollection = new RouteCollection();
$subCollection->add(...);
$subCollection->add(...);

$rootCollection->addCollection(
$subCollection,
$subCollection->addPrefix(
'/prefix', // prefix
array(), // requirements
array(), // options
'admin.example.com', // hostname
array('https') // schemes
);

$rootCollection->addCollection($subCollection);

.. versionadded:: 2.2
The ``addPrefixs`` method is added in Symfony2.2. This was part of the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra s here.

``addCollection`` method in older versions.

Set the Request Parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down