Skip to content

Commit badaae7

Browse files
committed
bug #3622 [Components][Routing] Fix addPrefix() sample code (bicpi)
This PR was merged into the 2.3 branch. Discussion ---------- [Components][Routing] Fix addPrefix() sample code | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | - The sample code used for demonstrating the [`Symfony\Component\Routing\RouteCollection::addPrefix()`](http://api.symfony.com/2.3/Symfony/Component/Routing/RouteCollection.html#method_addPrefix) method did not match the signature. I've updated the code to show the provided features when adding a nested route collection. + some minor fixes along the way. Commits ------- e095c13 [Components][Routing] Fix addPrefix() sample code
2 parents 1f384bc + e095c13 commit badaae7

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

book/routing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The route is simple:
6969
return $collection;
7070
7171
.. versionadded:: 2.2
72-
The ``path`` option is new in Symfony2.2, ``pattern`` is used in older
72+
The ``path`` option is new in Symfony 2.2, ``pattern`` is used in older
7373
versions.
7474

7575
The path defined by the ``blog_show`` route acts like ``/blog/*`` where
@@ -704,7 +704,7 @@ be accomplished with the following route configuration:
704704
return $collection;
705705
706706
.. versionadded:: 2.2
707-
The ``methods`` option is added in Symfony2.2. Use the ``_method``
707+
The ``methods`` option is added in Symfony 2.2. Use the ``_method``
708708
requirement in older versions.
709709

710710
Despite the fact that these two routes have identical paths (``/contact``),

components/routing/introduction.rst

+14-14
Original file line numberDiff line numberDiff line change
@@ -141,28 +141,26 @@ Using Prefixes
141141

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

148149
$rootCollection = new RouteCollection();
149150

150151
$subCollection = new RouteCollection();
151152
$subCollection->add(...);
152153
$subCollection->add(...);
153-
$subCollection->addPrefix(
154-
'/prefix', // prefix
155-
array(), // requirements
156-
array(), // options
157-
'admin.example.com', // host
158-
array('https') // schemes
159-
);
154+
$subCollection->addPrefix('/prefix');
155+
$subCollection->addDefaults(array(...));
156+
$subCollection->addRequirements(array(...));
157+
$subCollection->addOptions(array(...));
158+
$subCollection->setHost('admin.example.com');
159+
$subCollection->setMethods(array('POST'));
160+
$subCollection->setSchemes(array('https'));
160161

161162
$rootCollection->addCollection($subCollection);
162163

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

167165
Set the Request Parameters
168166
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -177,7 +175,9 @@ with this class via its constructor::
177175
$host = 'localhost',
178176
$scheme = 'http',
179177
$httpPort = 80,
180-
$httpsPort = 443
178+
$httpsPort = 443,
179+
$path = '/',
180+
$queryString = ''
181181
)
182182

183183
.. _components-routing-http-foundation:

0 commit comments

Comments
 (0)