From e095c134eb7269fd93998b484434f7f86b269bd1 Mon Sep 17 00:00:00 2001
From: Philipp Rieber
Date: Sat, 1 Mar 2014 20:59:07 +0100
Subject: [PATCH] [Components][Routing] Fix addPrefix() sample code
---
book/routing.rst | 4 ++--
components/routing/introduction.rst | 28 ++++++++++++++--------------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/book/routing.rst b/book/routing.rst
index 3abd34f79f0..0a760be23a8 100644
--- a/book/routing.rst
+++ b/book/routing.rst
@@ -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
@@ -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``),
diff --git a/components/routing/introduction.rst b/components/routing/introduction.rst
index 62e9840b451..a9f8a67ffa3 100644
--- a/components/routing/introduction.rst
+++ b/components/routing/introduction.rst
@@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -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: