@@ -16,13 +16,17 @@ You can configure the route enhancers that decide what controller is used to
16
16
handle the request, to avoid hard coding controller names into your route
17
17
documents.
18
18
19
- The minimum configuration required to load the dynamic router as service
20
- ``cmf_routing.dynamic_router `` is to have ``enabled: true `` in your
21
- application configuration, and to specify what route provider to use.
22
- The dynamic router is automatically enabled as soon as you add any other
23
- configuration to the ``dynamic `` entry. When not enabled, the dynamic router
24
- services will not be loaded at all, allowing you to use the ``ChainRouter ``
25
- with your own routers.
19
+ Configuration
20
+ -------------
21
+
22
+ The minimum configuration required to load the dynamic router is
23
+ to specify a route provider backend.
24
+
25
+ .. note ::
26
+
27
+ When your project is also using the :doc: `CoreBundle <../core/introduction >`,
28
+ it is enough to configure persistence on ``cmf_core `` and you do not need to
29
+ repeat the configuration for the dynamic router.
26
30
27
31
.. configuration-block ::
28
32
@@ -31,17 +35,21 @@ with your own routers.
31
35
# app/config/config.yml
32
36
cmf_routing :
33
37
dynamic :
34
- enabled : true
35
- # route provider configuration...
38
+ persistence :
39
+ phpcr :
40
+ enabled : true
36
41
37
42
.. code-block :: xml
38
43
39
44
<!-- app/config/config.xml -->
40
45
<?xml version =" 1.0" encoding =" UTF-8" ?>
41
46
<container xmlns =" http://symfony.com/schema/dic/services" >
42
47
<config xmlns =" http://cmf.symfony.com/schema/dic/routing" >
43
- <dynamic enabled =" true" />
44
- <!-- route provider configuration... -->
48
+ <dynamic >
49
+ <persistence >
50
+ <phpcr enabled =" true" />
51
+ </persistence >
52
+ </dynamic >
45
53
</config >
46
54
</container >
47
55
@@ -50,15 +58,22 @@ with your own routers.
50
58
// app/config/config.php
51
59
$container->loadFromExtension('cmf_routing', array(
52
60
'dynamic' => array(
53
- 'enabled' => true,
54
- // route provider configuration...
61
+ 'persistence' => array(
62
+ 'phpcr' => array(
63
+ 'enabled' => true,
64
+ ),
65
+ ),
55
66
),
56
67
));
57
68
69
+ When there is no configuration or ``cmf_routing.dynamic.enabled `` is set to
70
+ ``false ``, the dynamic router services will not be loaded at all, allowing
71
+ you to use the ``ChainRouter `` with your own routers.
72
+
58
73
.. _bundle-routing-dynamic-match :
59
74
60
75
Match Process
61
- ~~~~~~~~~~~~~
76
+ -------------
62
77
63
78
Most of the match process is described in the documentation of the
64
79
`CMF Routing component `_. The only difference is that this bundle will place
@@ -110,7 +125,7 @@ A custom controller action can look like this::
110
125
.. _bundles-routing-dynamic_router-enhancer :
111
126
112
127
Configuring the Controller for a Route
113
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128
+ --------------------------------------
114
129
115
130
To configure what controller is used for which route, you can configure the
116
131
*route enhancers *. Many of them operate on routes implementing
@@ -124,15 +139,15 @@ precedence):
124
139
#. (Explicit controller): If there is a ``_controller `` set in
125
140
``getRouteDefaults() ``, no enhancer will overwrite the controller.
126
141
``_template `` will still be inserted if its not already set;
127
- #. Controller by type : requires the route document to return a 'type' value in
142
+ #. `` controllers_by_type `` : requires the route document to return a 'type' value in
128
143
``getRouteDefaults() ``. **priority: 60 **;
129
- #. Controller by class : requires the route document to be an instance of
144
+ #. `` controllers_by_class `` : requires the route document to be an instance of
130
145
``RouteObjectInterface `` and to return an object for ``getRouteContent() ``.
131
146
The content document is checked for being ``instanceof `` the class names in
132
147
the map and if matched that controller is used. Instanceof is used instead of
133
148
direct comparison to work with proxy classes and other extending classes.
134
149
**priority: 50 **;
135
- #. Template by class : requires the route document to be an instance of
150
+ #. `` templates_by_class `` : requires the route document to be an instance of
136
151
``RouteObjectInterface `` and to return an object for ``getRouteContent() ``.
137
152
The content document is checked for being ``instanceof `` the class names in
138
153
the map and if matched that template will be set as ``'_template' ``.
@@ -203,7 +218,7 @@ All routes are located under a configured root path, for example
203
218
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route;
204
219
205
220
$route = new Route();
206
- $route->setParent ($dm->find(null, '/cms/routes'));
221
+ $route->setParentDocument ($dm->find(null, '/cms/routes'));
207
222
$route->setName('projects');
208
223
209
224
// set explicit controller (both service and Bundle:Name:action syntax work)
@@ -362,8 +377,8 @@ the name indicates, loads ``Route`` entities from an ORM database.
362
377
363
378
.. caution ::
364
379
365
- You must install the CoreBundle to utilize this feature if your app
366
- does not have at least DoctrineBundle 1.3 installed .
380
+ You must install the CoreBundle to use this feature if your application
381
+ does not have at least DoctrineBundle 1.3.0 .
367
382
368
383
.. _bundles-routing-dynamic-generator :
369
384
@@ -421,8 +436,9 @@ to generate a route:
421
436
422
437
.. caution ::
423
438
424
- It is dangerous to hardcode paths in your templates if the user has a way
425
- to edit and delete them. If the route must exist for sure, it probably
439
+ It is dangerous to hardcode paths to PHPCR-ODM documents into your
440
+ templates. An admin user could edit or delete them in a way that your
441
+ application breaks. If the route must exist for sure, it probably
426
442
should be a statically configured route. But route names could come from
427
443
code for example.
428
444
@@ -451,7 +467,7 @@ object that implements this interface and provides a route for it:
451
467
452
468
Additionally, the generator also understands the ``content_id `` parameter with
453
469
an empty route name and tries to find a content implementing the
454
- ``RouteReferrersInterface `` from the configured content repository.
470
+ ``RouteReferrersInterface `` from the configured content repository:
455
471
456
472
.. configuration-block ::
457
473
0 commit comments