Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 3236384

Browse files
committed
Merge pull request #127 from WouterJ/components_fix_standards
[Components] Fixed standards
2 parents 335c564 + d84fe4a commit 3236384

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

components/routing.rst

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
.. index::
2+
single: Routing
3+
single: Components; Routing
4+
15
Routing
26
=======
37

4-
The `Symfony CMF Routing component <https://github.com/symfony-cmf/Routing>`_
8+
The `Symfony CMF Routing component`_
59
library extends the Symfony2 core routing component. Even though it has Symfony
610
in its name, it does not need the full Symfony2 framework and can be used in
711
standalone projects. For integration with Symfony we provide
@@ -18,7 +22,7 @@ Additionally, this component is meant to provide useful implementations of the
1822
routing interfaces. Currently, it provides the ``DynamicRouter``, which uses
1923
a ``RequestMatcherInterface`` to dynamically load Routes, and can apply ``RouteEnhancerInterface``
2024
strategies in order to manipulate them. The provided ``NestedMatcher`` can
21-
dynamically retrieve Symfony2 `Route <http://api.symfony.com/master/Symfony/Component/Routing/Route.html>`_
25+
dynamically retrieve Symfony2 :class:`Symfony\\Component\\Routing\\Route`
2226
objects from a ``RouteProviderInterface``. This interfaces abstracts a collection
2327
of Routes, that can be stored in a database, like Doctrine PHPCR-ODM or Doctrine ORM.
2428
The ``DynamicRouter`` also uses a ``UrlGenerator`` instance to generate Routes
@@ -30,17 +34,15 @@ a content object.
3034
.. note::
3135

3236
To use this component outside of the Symfony2 framework context, have
33-
a look at the core Symfony2 `Routing <https://github.com/symfony/Routing>`__
37+
a look at the core Symfony2 `Routing`_
3438
to get a fundamental understanding of the component. CMF Routing just extends
3539
the basic behaviour.
3640

37-
.. index:: Routing
38-
3941
Dependencies
4042
------------
4143

42-
This component uses `composer <http://getcomposer.org>`_. It needs the
43-
Symfony2 Routing component and the Symfony2 HttpKernel (for the logger
44+
This component uses `Composer`_. It needs the
45+
Symfony2 `Routing`_ component and the Symfony2 `HttpKernel`_ (for the logger
4446
interface and cache warm-up interface).
4547

4648
For the ``DynamicRouter`` you will need something to implement the
@@ -57,31 +59,31 @@ need to determine which Controller will handle this request - in the full
5759
stack Symfony2 framework, this is identified by the ``_controller`` field
5860
of the parameters.
5961

60-
The ``ChainRouter`` works by accepting a set of prioritized routing strategies,
61-
`RouterInterface <http://api.symfony.com/master/Symfony/Component/Routing/RouterInterface.html>`_
62+
The ``ChainRouter`` works by accepting a set of prioritized routing
63+
strategies, :class:`Symfony\\Component\\Routing\\RouterInterface`
6264
implementations, commonly referred to as "Routers".
6365

64-
When handling an incoming request, the ChainRouter iterates over the configured Routers,
65-
by their configured priority, until one of them is able to `match <http://api.symfony.com/2.1/Symfony/Component/Routing/RouterInterface.html#method_match>`_
66-
the request and provide the request parameters.
66+
When handling an incoming request, the ``ChainRouter`` iterates over the
67+
configured routers, by their configured priority, until one of them is able to
68+
:method:`Symfony\\Component\\Routing\\RouterInterface::match` the request and
69+
provide the request parameters.
6770

6871
Routers
6972
-------
7073

7174
The ``ChainRouter`` is incapable of, by itself, making any actual routing decisions.
7275
Its sole responsibility is managing the given set of Routers, which are responsible for matching a request and determining its parameters.
7376

74-
You can easily create your own Routers by implementing
75-
`RouterInterface <http://api.symfony.com/master/Symfony/Component/Routing/RouterInterface.html>`_
76-
but Symfony CMF already includes a powerful route matching system that you can
77-
extend to your needs.
77+
You can easily create your own routers by implementing
78+
:class:`Symfony\\Component\\Routing\\RouterInterface` but Symfony CMF already
79+
includes a powerful route matching system that you can extend to your needs.
7880

7981
.. note::
8082

8183
If you are using this as part of a full Symfony CMF project, please refer to
8284
:doc:`../bundles/routing-extra` for instructions on how to add Routers to
8385
the ``ChainRouter``. Otherwise, use the ``ChainRouter``'s ``add`` method to
84-
configure new Routers.
86+
configure new routers.
8587

8688
Symfony2 Default Router
8789
~~~~~~~~~~~~~~~~~~~~~~~
@@ -102,7 +104,7 @@ and modify the resulting parameters using a set of enhancers that can be
102104
easily configured, greatly extending Symfony2's default functionality.
103105

104106
Matcher
105-
^^^^^^^
107+
.......
106108

107109
The ``DynamicRouter`` uses a ``RequestMatcherInterface`` or ``UrlMatcherInterface``
108110
instance to match the received Request or URL, respectively, to a parameters array.
@@ -111,20 +113,19 @@ You can easily use you own matching strategy by passing it to the ``DynamicRoute
111113
constructor. As part of this bundle, a ``NestedMatcher`` is already provided
112114
which you can use straight away, or as reference for your own implementation.
113115

114-
115116
Its other feature are the ``RouteEnhancerInterface`` strategies used to infer
116117
routing parameters from the information provided by the match (see below).
117118

118119
NestedMatcher
119-
^^^^^^^^^^^^^
120+
.............
120121

121122
The provided ``RequestMatcherInterface`` implementation is ``NestedMatcher``.
122123
It is suitable for use with ``DynamicRouter``, and it uses a multiple step
123124
matching process to determine the resulting routing parameters from a given
124-
`Request <http://api.symfony.com/master/Symfony/Component/HttpFoundation/Request.html>`_.
125+
:class:`Symfony\\Component\\HttpFoundation\\Request`.
125126

126127
It uses a ``RouteProviderInterface`` implementation, which is capable of
127-
loading candidate `Route <http://api.symfony.com/master/Symfony/Component/Routing/Route.html>`_
128+
loading candidate :class:`Symfony\\Component\\Routing\\Route`
128129
objects for a Request dynamically from a data source. Although it can be used
129130
in other ways, the ``RouteProviderInterface``'s main goal is to be easily
130131
implemented on top of Doctrine PHPCR ODM or a relational database,
@@ -137,8 +138,8 @@ to use when handling the current Request:
137138
* Apply all ``RouteFilterInterface`` to filter down this collection
138139
* Let the ``FinalMatcherInterface`` instance decide on the best match among the remaining ``Route`` instances and transform it into the parameter array.
139140

140-
RouteProviderInterface
141-
""""""""""""""""""""""
141+
``RouteProviderInterface``
142+
""""""""""""""""""""""""""
142143

143144
Based on the ``Request``, the ``NestedMatcher`` will retrieve an ordered
144145
collection of ``Route`` objects from the ``RouteProviderInterface``. The idea
@@ -148,28 +149,29 @@ later steps.
148149

149150
The underlying implementation of the ``RouteProviderInterface`` is not in the
150151
scope of this bundle. Please refer to the interface declaration for more
151-
information. For a functional example, see `RoutingExtraBundle <https://github.com/symfony-cmf/RoutingExtraBundle>`_.
152+
information. For a functional example, see :doc:`../bundles/routing-extra`.
152153

153-
RouteFilterInterface
154-
""""""""""""""""""""
154+
``RouteFilterInterface``
155+
""""""""""""""""""""""""
155156

156157
The ``NestedMatcher`` can apply user provided ``RouteFilterInterface`` implementations
157158
to reduce the provided ``Route`` objects, e.g. for doing content negotiation.
158159
It is the responsibility of each filter to throw the ``ResourceNotFoundException`` if
159160
no more routes are left in the collection.
160161

161-
FinalMatcherInterface
162-
"""""""""""""""""""""
162+
``FinalMatcherInterface``
163+
"""""""""""""""""""""""""
163164

164165
The ``FinalMatcherInterface`` implementation has to determine exactly one
165166
Route as the best match or throw an exception if no adequate match could
166-
be found. The default implementation uses the `UrlMatcher <http://api.symfony.com/2.1/Symfony/Component/Routing/Matcher/UrlMatcher.html>`_
167-
of the Symfony Routing Component.
167+
be found. The default implementation uses the
168+
:class:`Symfony\\Component\\Routing\\Matcher\\UrlMatcher` of the Symfony
169+
Routing Component.
168170

169171
.. _component-routing-enhancers:
170172

171173
Route Enhancers
172-
^^^^^^^^^^^^^^^
174+
...............
173175

174176
Optionally, and following the matching process, a set of ``RouteEnhancerInterface``
175177
instances can be applied by the ``DynamicRouter``. The aim of these is to allow you to
@@ -179,7 +181,7 @@ example, to dynamically assign a controller or template to a ``Route`` or to
179181
packed with the bundle, documentation can be found inside each class file.
180182

181183
Linking a Route with a Content
182-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
184+
..............................
183185

184186
Depending on your application's logic, a requested url may have an associated
185187
content from the database. Those Routes should implement the
@@ -199,7 +201,7 @@ route instance and put the provided name into _route_name.
199201
All routes still need to extend the base class ``Symfony\Component\Routing\Route``.
200202

201203
Redirections
202-
^^^^^^^^^^^^
204+
............
203205

204206
You can build redirections by implementing the ``RedirectRouteInterface``.
205207
It can redirect either to an absolute URI, to a named Route that can be
@@ -211,7 +213,6 @@ should implement your own logic to handle the redirection. For an example on
211213
implementing that redirection under the full Symfony2 stack, refer to
212214
:doc:`../bundles/routing-extra`.
213215

214-
215216
Generating URLs
216217
~~~~~~~~~~~~~~~
217218

@@ -220,14 +221,13 @@ is also responsible for generating an URL from a Route and its parameters.
220221
The ``ChainRouter`` iterates over its known routers until one of them is
221222
able to generate a matching URL.
222223

223-
224224
Apart from using ``RequestMatcherInterface`` or ``UrlMatcherInterface`` to
225225
match a Request/URL to its corresponding parameters, the ``DynamicRouter``
226226
also uses an ``UrlGeneratorInterface`` instance, which allows it to
227227
generate an URL from a Route.
228228

229229
The included ``ProviderBasedGenerator`` extends Symfony2's default
230-
`UrlGenerator <http://api.symfony.com/master/Symfony/Component/Routing/Generator/UrlGenerator.html>`_
230+
:class:`Symfony\\Component\\routing\\Generator\\UrlGenerator`
231231
(which, in turn, implements ``UrlGeneratorInterface``) and - if $name is
232232
not already a ``Route`` object - loads the route from the ``RouteProviderInterface``.
233233
It then lets the core logic generate the URL from that Route.
@@ -262,7 +262,6 @@ locale system.
262262

263263
If you need translated URLs, make the locale part of the route name.
264264

265-
266265
Customization
267266
-------------
268267

@@ -292,9 +291,8 @@ a look at :doc:`../bundles/routing-extra`.
292291
For a starter's guide to the Routing bundle and its integration with Symfony2,
293292
refer to :doc:`../getting-started/routing`
294293

295-
We strongly recommend reading Symfony2's
296-
`Routing <http://symfony.com/doc/current/components/routing/introduction.html>`__
297-
component documentation page, as it's the base of this bundle's implementation.
294+
We strongly recommend reading Symfony2's `Routing`__ component documentation
295+
page, as it's the base of this bundle's implementation.
298296

299297
Authors
300298
-------
@@ -305,6 +303,12 @@ Authors
305303
* Lukas Kahwe Smith (lsmith77)
306304
* David Buchmann (dbu)
307305
* Larry Garfield (Crell)
308-
* `And others <https://github.com/symfony-cmf/Routing/contributors>`_
306+
* `And others`_
309307

310308
The original code for the chain router was contributed by Magnus Nordlander.
309+
310+
.. _`Symfony CMF Routing component`: https://github.com/symfony/symfony-docs/issues?milestone=1&state=open
311+
.. _`Routing`: http://symfony.com/doc/current/components/routing/introduction.html
312+
.. _`Composer`: http://getcomposer.org
313+
.. _`HttpKernel`: http://symfony.com/doc/current/components/http_kernel/introduction.html
314+
.. _`And others`: https://github.com/symfony/symfony-docs/issues?milestone=1&state=open

0 commit comments

Comments
 (0)