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

Commit 5310fa0

Browse files
committed
documentation for cleaned up routing
1 parent 20364d7 commit 5310fa0

File tree

2 files changed

+77
-15
lines changed

2 files changed

+77
-15
lines changed

bundles/routing/dynamic.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,20 @@ need content, you can just not set it in the route document.
263263
from content instances. When resolving the route, the ``_locale`` gets
264264
into the request and is picked up by the Symfony2 locale system.
265265

266+
Make sure you configure the valid locales in the configuration so that the
267+
bundle can optimally handle locales. The
268+
:ref:`configuration reference <reference-config-routing-locales>` lists
269+
some options to tweak behaviour and performance.
270+
266271
.. note::
267272

268-
Under PHPCR-ODM, Routes should never be translatable documents, as one
273+
Under PHPCR-ODM, Routes should not be translatable documents, as one
269274
Route document represents one single url, and serving several translations
270275
under the same url is not recommended.
271276

272-
If you need translated URLs, make the locale part of the route name and use
273-
several routes for the same content. The route generator will pick the
274-
correct route if available.
277+
If you need translated URLs, make the ``locale`` part of the route name and
278+
create one route per language for the same content. The route generator will
279+
pick the correct route if available.
275280

276281
Sonata Doctrine PHPCR-ODM Admin classes
277282
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -288,6 +293,10 @@ get an error if Sonata becomes unavailable.
288293
Sonata admin is using the ``content_basepath`` to show the tree of content to
289294
select the route target.
290295

296+
The root path to add Routes defaults to the first entry in ``route_basepaths``
297+
but you can overwrite this with the ``admin_basepath`` if you need a different
298+
base path.
299+
291300
.. configuration-block::
292301

293302
.. code-block:: yaml

reference/configuration/routing.rst

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,11 @@ phpcr
305305
phpcr:
306306
enabled: false
307307
manager_name: ~
308-
route_basepath: /cms/routes
308+
route_basepaths:
309+
- /cms/routes
310+
- /cms/simple
309311
content_basepath: /cms/content
312+
admin_basepath: /cms/routes
310313
use_sonata_admin: auto
311314
312315
.. code-block:: xml
@@ -320,10 +323,13 @@ phpcr
320323
<phpcr
321324
enabled="false"
322325
manager-name="null"
323-
route-basepath="/cms/routes"
324326
content-basepath="/cms/content"
327+
admin-basepath="/cms/routes"
325328
use-sonata-admin="auto"
326-
/>
329+
>
330+
<route-basepath>/cms/routes</route-basepath>
331+
<route-basepath>/cms/simple</route-basepath>
332+
</phpcr>
327333
</persistence>
328334
</dynamic>
329335
</config>
@@ -337,8 +343,12 @@ phpcr
337343
'phpcr' => array(
338344
'enabled' => false,
339345
'manager_name' => null,
340-
'route_basepath' => '/cms/routes',
346+
'route_basepaths' => array(
347+
'/cms/routes',
348+
'/cms/simple',
349+
)
341350
'content_basepath' => '/cms/content',
351+
'admin_basepath' => '/cms/routes',
342352
'use_sonata_admin' => 'auto',
343353
),
344354
),
@@ -356,27 +366,37 @@ manager_name
356366

357367
.. include:: partials/persistence_phpcr_manager_name.rst.inc
358368

359-
route_basepath
369+
route_basepaths
360370
**************
361371

362-
**type**: ``string`` **default**: ``/cms/routes``
372+
**type**: ``array`` **default**: ``array('/cms/routes')``
363373

364-
The basepath for routes in the PHPCR tree.
374+
The basepaths where to look for routes in the PHPCR tree.
365375

366-
If the :doc:`CoreBundle <../../bundles/core/index>` is registered, this will default to
367-
``%cmf_core.persistence.phpcr.basepath%/routes``.
376+
If the :doc:`CoreBundle <../../bundles/core/index>` is registered, this will
377+
default to ``%cmf_core.persistence.phpcr.basepath%/routes``. If the
378+
:doc:`SimpleCmsBundle <../../bundles/simplecms/index>` is registered as well,
379+
this will additionally default to ``%cmf_core.persistence.phpcr.basepath%/simple``.
368380

369381
content_basepath
370382
****************
371383

372-
**type**: ``content_basepath`` **default**: ``/cms/content``
384+
**type**: ``string`` **default**: ``/cms/content``
373385

374386
The basepath for content objects in the PHPCR tree. This information is used
375387
with the sonata admin to offer the correct subtree to select content documents.
376388

377389
If the :doc:`CoreBundle <../../bundles/core/index>` is registered, this will default to
378390
``%cmf_core.persistence.phpcr.basepath%/content``.
379391

392+
admin_basepath
393+
**************
394+
395+
**type**: ``string`` **default**: first value of route_basepaths
396+
397+
The path at which to create routes with Sonata admin. There can be additional
398+
route basepaths, but you will need your own tools to edit those.
399+
380400
use_sonata_admin
381401
****************
382402

@@ -487,12 +507,45 @@ content repository service.
487507
This can be overriden by this option. ORM doesn't have a content
488508
repository at the moment.
489509

510+
.. _reference-config-routing-locales:
511+
490512
locales
491513
~~~~~~~
492514

493-
**type**: ``array`` **default**:
515+
**type**: ``array`` **default**: ``array()``
494516

495517
To enable multilanguage, set the valid locales in this option.
496518

497519
If the :doc:`CoreBundle <../../bundles/core/index>` is registered, this will default to the value
498520
of ``cmf_core.locales``.
521+
522+
match_implicit_locale
523+
~~~~~~~~~~~~~~~~~~~~~
524+
525+
**type**: ``boolean`` **default**: ``true``
526+
527+
Whether the route provider should look for routes without the locale.
528+
529+
For example, when the ``locales`` are ``de`` and ``en`` and the request has the
530+
url ``de/my/path``, the route provider will not only look for ``de/my/path``,
531+
``de/my`` and ``de`` but also for ``my/path`` and ``my``. This allows to use a
532+
single route for multiple languages. This is used for example by the
533+
:doc:`SimpleCms <../../bundles/simple_cms/index>`.
534+
535+
If you do not need this, disabling the option will gain some performance.
536+
537+
auto_locale_pattern
538+
~~~~~~~~~~~~~~~~~~~
539+
540+
**type**: ``boolean`` **default**: ``false``
541+
542+
If you enable this option, the LocaleListener will ensure that routes that have
543+
no locale in their static pattern get the ``auto_locale_pattern`` option set.
544+
545+
.. note::
546+
547+
Enabling this option will prevent you from having any CMF Routes that match
548+
URL without a locale in it.
549+
550+
This is ignored if there are no ``locales`` configured. It makes no sense to
551+
enable this option when ``match_implicit_locale`` is disabled.

0 commit comments

Comments
 (0)