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

Commit ad2de8f

Browse files
authored
Merge pull request #804 from symfony-cmf/bp-routing
[routing] change doc to best practices
2 parents aeab7bd + 1bc0bfc commit ad2de8f

File tree

4 files changed

+190
-151
lines changed

4 files changed

+190
-151
lines changed

bundles/routing/configuration.rst

Lines changed: 75 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ To add the ``DynamicRouter``, use the following configuration:
2828

2929
.. code-block:: yaml
3030
31+
# app/config/config.yml
3132
cmf_routing:
3233
chain:
3334
routers_by_id:
@@ -36,6 +37,7 @@ To add the ``DynamicRouter``, use the following configuration:
3637
3738
.. code-block:: xml
3839
40+
<!-- app/config/config.xml -->
3941
<?xml version="1.0" encoding="UTF-8" ?>
4042
<container xmlns="http://symfony.com/schema/dic/services">
4143
@@ -50,14 +52,15 @@ To add the ``DynamicRouter``, use the following configuration:
5052
5153
.. code-block:: php
5254
53-
$container->loadFromExtension('cmf_routing', array(
54-
'chain' => array(
55-
'routers_by_id' => array(
55+
// app/config/config.php
56+
$container->loadFromExtension('cmf_routing', [
57+
'chain' => [
58+
'routers_by_id' => [
5659
'cmf_routing.dynamic_router' => 200,
5760
'router.default' => 100,
58-
),
59-
),
60-
));
61+
],
62+
],
63+
]);
6164
6265
.. tip::
6366

@@ -79,12 +82,14 @@ default router, because :ref:`no other routers were set <reference-config-routin
7982

8083
.. code-block:: yaml
8184
85+
# app/config/config.yml
8286
cmf_routing:
8387
chain:
8488
replace_symfony_router: true
8589
8690
.. code-block:: xml
8791
92+
<!-- app/config/config.xml -->
8893
<?xml version="1.0" encoding="UTF-8" ?>
8994
<container xmlns="http://symfony.com/schema/dic/services">
9095
@@ -98,11 +103,12 @@ default router, because :ref:`no other routers were set <reference-config-routin
98103
99104
.. code-block:: php
100105
101-
$container->loadFromExtension('cmf_routing', array(
102-
'chain' => array(
106+
// app/config/config.php
107+
$container->loadFromExtension('cmf_routing', [
108+
'chain' => [
103109
'replace_symfony_router' => true,
104-
),
105-
));
110+
],
111+
]);
106112
107113
108114
.. _reference-config-routing-dynamic:
@@ -123,10 +129,9 @@ generic_controller
123129

124130
**type**: ``string`` **default**: ``null``
125131

126-
The controller to use when the route enhancers only determined the template but
127-
no explicit controller. The value is the name of a controller using either the
128-
``AcmeDemoBundle::Page::index`` or ``acme_demo.controller.page:indexAction``
129-
notation.
132+
This configuration specifies the controller that is used when the route
133+
enhancers define a template but no explicit controller. It accepts any valid
134+
Symfony controller reference.
130135

131136
If the :doc:`CoreBundle <../core/introduction>` and
132137
:doc:`ContentBundle <../content/introduction>` are registered, this
@@ -139,7 +144,7 @@ defaults to ``cmf_content.controller:indexAction``.
139144

140145
The default controller to use if none of the enhancers found a controller. The
141146
value is the name of a controller using either the
142-
``AcmeDemoBundle::Page::index`` or ``acme_demo.controller.page:indexAction``
147+
``AppBundle::Page::index`` or ``app.page_controller:indexAction``
143148
notation.
144149

145150
``controllers_by_type``
@@ -155,34 +160,36 @@ type:
155160

156161
.. code-block:: yaml
157162
163+
# app/config/config.yml
158164
cmf_routing:
159165
dynamic:
160166
controllers_by_type:
161-
editable: acme_main.controller:editableAction
167+
editable: AppBundle:Cms:editable
162168
163169
.. code-block:: xml
164170
165-
171+
<!-- app/config/config.xml -->
166172
<?xml version="1.0" encoding="UTF-8" ?>
167173
<container xmlns="http://symfony.com/schema/dic/services">
168174
169175
<config xmlns="http://cmf.symfony.com/schema/dic/routing">
170176
<dynamic>
171-
<controller-by-type type="editable">acme_main.controller:editableAction</controller-by-type>
177+
<controller-by-type type="editable">AppBundle:Cms:editable</controller-by-type>
172178
</dynamic>
173179
</config>
174180
175181
</container>
176182
177183
.. code-block:: php
178184
179-
$container->loadFromExtension('cmf_routing', array(
180-
'dynamic' => array(
181-
'controllers_by_type' => array(
182-
'editable' => 'acme_main.controller:editableAction',
183-
),
184-
),
185-
));
185+
// app/config/config.php
186+
$container->loadFromExtension('cmf_routing', [
187+
'dynamic' => [
188+
'controllers_by_type' => [
189+
'editable' => 'AppBundle:Cms:editable',
190+
],
191+
],
192+
]);
186193
187194
controllers_by_class
188195
....................
@@ -203,13 +210,15 @@ choose this controller to handle the request.
203210

204211
.. code-block:: yaml
205212
213+
# app/config/config.yml
206214
cmf_routing:
207215
dynamic:
208216
controllers_by_class:
209217
Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent: cmf_content.controller:indexAction
210218
211219
.. code-block:: xml
212220
221+
<!-- app/config/config.xml -->
213222
<?xml version="1.0" encoding="UTF-8" ?>
214223
<container xmlns="http://symfony.com/schema/dic/services">
215224
@@ -226,10 +235,13 @@ choose this controller to handle the request.
226235
227236
.. code-block:: php
228237
229-
$container->loadFromExtension('cmf_routing', array(
230-
'dynamic' => array(
231-
'controllers_by_class' => array(
232-
'Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent' => 'cmf_content.controller:indexAction',
238+
// app/config/config.php
239+
use Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent;
240+
241+
$container->loadFromExtension('cmf_routing', [
242+
'dynamic' => [
243+
'controllers_by_class' => [
244+
StaticContent::class => 'cmf_content.controller:indexAction',
233245
),
234246
),
235247
));
@@ -255,16 +267,17 @@ setting is set as controller.
255267

256268
.. code-block:: yaml
257269
270+
# app/config/config.yml
258271
cmf_routing:
259272
dynamic:
260273
templates_by_class:
261274
Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent: CmfContentBundle:StaticContent:index.html.twig
262275
263276
.. code-block:: xml
264277
278+
<!-- app/config/config.xml -->
265279
<?xml version="1.0" encoding="UTF-8" ?>
266280
<container xmlns="http://symfony.com/schema/dic/services">
267-
268281
<config xmlns="http://cmf.symfony.com/schema/dic/routing">
269282
<dynamic>
270283
<template-by-class
@@ -278,10 +291,13 @@ setting is set as controller.
278291
279292
.. code-block:: php
280293
281-
$container->loadFromExtension('cmf_routing', array(
282-
'dynamic' => array(
283-
'templates_by_class' => array(
284-
'Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent' => 'CmfContentBundle:StaticContent:index.html.twig',
294+
// app/config/config.php
295+
use Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent;
296+
297+
$container->loadFromExtension('cmf_routing', [
298+
'dynamic' => [
299+
'templates_by_class' => [
300+
StaticContent::class => 'CmfContentBundle:StaticContent:index.html.twig',
285301
),
286302
),
287303
));
@@ -349,24 +365,25 @@ disables the limit entirely.
349365
350366
.. code-block:: php
351367
352-
$container->loadFromExtension('cmf_routing', array(
353-
'dynamic' => array(
354-
'persistence' => array(
355-
'phpcr' => array(
368+
# app/config/config.php
369+
$container->loadFromExtension('cmf_routing', [
370+
'dynamic' => [
371+
'persistence' => [
372+
'phpcr' => [
356373
'enabled' => false,
357374
'manager_name' => null,
358-
'route_basepaths' => array(
375+
'route_basepaths' => [
359376
'/cms/routes',
360377
'/cms/simple',
361-
)
378+
],
362379
'content_basepath' => '/cms/content',
363380
'admin_basepath' => '/cms/routes',
364381
'use_sonata_admin' => 'auto',
365382
'enable_initializer' => true,
366-
),
367-
),
368-
),
369-
));
383+
],
384+
],
385+
],
386+
]);
370387
371388
enabled
372389
*******
@@ -470,7 +487,7 @@ If ``true``, the ORM is included in the service container.
470487
The name of the Doctrine Manager to use.
471488

472489
``route_class``
473-
****************
490+
***************
474491

475492
**type**: ``string`` **default**: ``'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route'``
476493

@@ -511,34 +528,36 @@ priority.
511528

512529
.. code-block:: yaml
513530
531+
# app/config/config.yml
514532
cmf_routing:
515533
dynamic:
516534
route_filters_by_id:
517-
acme_main.routing.foo_filter: 100
535+
app.routing_filter: 100
518536
519537
.. code-block:: xml
520538
521-
539+
<!-- app/config/config.xml -->
522540
<?xml version="1.0" encoding="UTF-8" ?>
523541
<container xmlns="http://symfony.com/schema/dic/services">
524542
525543
<config xmlns="http://cmf.symfony.com/schema/dic/routing">
526544
<dynamic>
527-
<route-filter-by-id id="acme_main.routing.foo_filter">100</route-filter-by-id>
545+
<route-filter-by-id id="app.routing_filter">100</route-filter-by-id>
528546
</dynamic>
529547
</config>
530548
531549
</container>
532550
533551
.. code-block:: php
534552
535-
$container->loadFromExtension('cmf_routing', array(
536-
'dynamic' => array(
537-
'route_filters_by_id' => array(
538-
'acme_main.routing.foo_filter' => 100,
539-
),
540-
),
541-
));
553+
// app/config/config.php
554+
$container->loadFromExtension('cmf_routing', [
555+
'dynamic' => [
556+
'route_filters_by_id' => [
557+
'app.routing_filter' => 100,
558+
],
559+
],
560+
]);
542561
543562
``content_repository_service_id``
544563
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -568,7 +587,7 @@ service.
568587
``locales``
569588
~~~~~~~~~~~
570589

571-
**type**: ``array`` **default**: ``array()``
590+
**type**: ``array`` **default**: ``[]``
572591

573592
To enable multi-language, set the valid locales in this option.
574593

0 commit comments

Comments
 (0)