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

Commit 0dde272

Browse files
committed
Removed duplicated text
1 parent 98d1540 commit 0dde272

File tree

2 files changed

+39
-43
lines changed

2 files changed

+39
-43
lines changed

bundles/routing.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,24 @@ as we set a content on the route. The content could be used to define an intro
314314
section that is the same for each project or other shared data. If you don't
315315
need content, you can just not set it in the document.
316316

317+
.. _component-route-generator-and-locales:
318+
319+
.. sidebar:: ContentAwareGenerator and locales
320+
321+
You can use the ``_locale`` default value in a Route to create one Route
322+
per locale, all referencing the same multilingual content instance. The
323+
``ContentAwareGenerator`` respects the ``_locale`` when generating routes
324+
from content instances. When resolving the route, the ``_locale`` gets
325+
into the request and is picked up by the Symfony2 locale system.
326+
327+
.. note::
328+
329+
Under PHPCR-ODM, Routes should never be translatable documents, as one
330+
Route document represents one single url, and serving several translations
331+
under the same url is not recommended.
332+
333+
If you need translated URLs, make the locale part of the route name.
334+
317335
Sonata Admin Configuration
318336
--------------------------
319337

components/routing.rst

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Routing
77

88
The Symfony CMF Routing component extends the Symfony2 core routing
99
component. Even though it has Symfony in its name, it does not need the full
10-
Symfony2 Framework and can be used in standalone projects. For integration
11-
with the Symfony2 Framework, we provide :doc:`../bundles/routing`.
10+
Symfony2 Framework and can be used in standalone projects.
1211

1312
At the core of the Symfony CMF Routing component is the `ChainRouter`_. The
1413
ChainRouter tries to match a request with each of its registered routers,
@@ -297,7 +296,8 @@ Routing Component and is called
297296
You can create your own final matcher by implementing
298297
``Symfony\Cmf\Component\Routing\NestedMatcher\FinalMatcherInterface``.
299298

300-
The final matcher is set using the second argument of the constructor::
299+
The final matcher is set using the second argument of the constructor of the
300+
``NestedMatcher``::
301301

302302
use Symfony\Cmf\Component\Routing\NestedMatcher\UrlMatcher
303303
// ...
@@ -330,13 +330,13 @@ optional second argument to provide the priority.
330330
Linking a Route with a Content
331331
..............................
332332

333-
Depending on your application's logic, a requested url may have associated
334-
content from the database. Those Routes should implement the
335-
``RouteObjectInterface`` and can optionally return a model instance. If you
336-
configure the ``RouteContentEnhancer``, it will included that content in the
337-
match array, using the ``_content`` key. Notice that a Route can implement the
338-
above mentioned interface but still not to return any model instance, in which
339-
case no associated object will be returned.
333+
Depending on your application's logic, a requested url may have an associated
334+
content object. A route for such URL may implement the ``RouteObjectInterface``
335+
to return a content object if present. If you configure the
336+
``RouteContentEnhancer``, it will included that content in the match array,
337+
using the ``_content`` key. Notice that a Route can implement the above
338+
mentioned interface but still not to return any model instance, in which case
339+
no associated object will be returned.
340340

341341
Furthermore, routes that implement this interface can also provide a custom
342342
Route name. The key returned by ``getRouteKey`` will be used as route name
@@ -354,7 +354,7 @@ Redirections
354354

355355
You can build redirections by implementing the ``RedirectRouteInterface``.
356356
It can redirect to an absolute URI, a named Route that can be generated by any
357-
Router in the chain and to another Route object provided by the Route.
357+
Router in the chain or to another Route object provided by the Route.
358358

359359
Notice that the actual redirection logic is not handled by the bundle. You
360360
should implement your own logic to handle the redirection. For an example of
@@ -371,19 +371,18 @@ able to generate a matching URL.
371371

372372
Beside ``RequestMatcherInterface`` and ``UrlMatcherInterface`` to match a
373373
Request/URL to its corresponding parameters, the ``DynamicRouter`` also uses
374-
an ``UrlGeneratorInterface`` instance, which allows it to generate an URL from
374+
a ``UrlGeneratorInterface`` instance, which allows it to generate an URL from
375375
a Route.
376376

377377
The included ``ProviderBasedGenerator`` extends Symfony2's default
378-
:class:`Symfony\\Component\\routing\\Generator\\UrlGenerator`
379-
(which, in turn, implements ``UrlGeneratorInterface``) and - if the name is
380-
not already a ``Route`` object - loads the Route from the
381-
Route provider. It then lets the core logic generate the URL from
382-
that Route.
378+
:class:`Symfony\\Component\\routing\\Generator\\UrlGenerator` (which, in turn,
379+
implements ``UrlGeneratorInterface``) and - if the name is not already a
380+
``Route`` object - loads the Route from the Route provider. It then lets the
381+
core logic generate the URL from that Route.
383382

384383
The component also includes the ``ContentAwareGenerator``, which extends the
385384
``ProviderBasedGenerator`` to check if the name is an object implementing
386-
``RouteAwareInterface`` and, if so, gets the Route from the content.
385+
``RouteReferrersReadInterface`` and, if so, gets the Route from the content.
387386
Using the ``ContentAwareGenerator``, you can generate urls for your content in
388387
three ways:
389388

@@ -392,34 +391,13 @@ three ways:
392391
* Or provide an implementation of ``ContentRepositoryInterface`` and pass the id
393392
of the content object as parameter ``content_id`` and ``null`` as $name.
394393

395-
.. _component-route-generator-and-locales:
396-
397-
.. sidebar:: ContentAwareGenerator and locales
398-
399-
You can use the ``_locale`` default value in a Route to create one Route
400-
per locale, all referencing the same multilingual content instance. The
401-
``ContentAwareGenerator`` respects the ``_locale`` when generating routes
402-
from content instances. When resolving the route, the ``_locale`` gets
403-
into the request and is picked up by the Symfony2 locale system.
404-
405-
.. note::
406-
407-
Under PHPCR-ODM, Routes should never be translatable documents, as one
408-
Route document represents one single url, and serving several translations
409-
under the same url is not recommended.
410-
411-
If you need translated URLs, make the locale part of the route name.
412-
413394
Symfony2 integration
414395
--------------------
415396

416-
Like mentioned before, this bundle was designed to only require certain parts
417-
of Symfony2. However, if you wish to use it as part of your Symfony CMF project,
418-
an integration bundle is also available. We strongly recommend that you take
419-
a look at ":doc:`../bundles/routing`" in the bundles documentation.
420-
421-
We strongly recommend reading Symfony2's `Routing`_ component documentation
422-
page, as it's the base of this bundle's implementation.
397+
As mentioned before, this component was designed to use independently of the
398+
Symfony2 framework. However, if you wish to use it as part of your Symfony
399+
CMF project, an integration bundle is also available. Read more about the
400+
RoutingBundle in ":doc:`../bundles/routing`" in the bundles documentation.
423401

424402
.. _`Install it via Composer`: http://symfony.com/doc/current/components/using_components.html
425403
.. _`Packagist`: https://packagist.org/packages/symfony-cmf/routing

0 commit comments

Comments
 (0)