@@ -22,11 +22,59 @@ Writing your own Route Enhancers
22
22
23
23
You can add your own :ref: `RouteEnhancerInterface <bundles-routing-dynamic_router-enhancer >`
24
24
implementations if you have a case not handled by the
25
- :ref: `provided enhancers <component-routing-enhancers >`. Simply define services
26
- for your enhancers and tag them with ``dynamic_router_route_enhancer `` to have
27
- them added to the routing.
25
+ :ref: `provided enhancers <component-routing-enhancers >`.
26
+
27
+ .. code-block :: php
28
+
29
+ // src/AppBundle/Routing/Enhancer/SimpleEnhancer.php
30
+ namespace AppBundle\Routing\Enhancer;
31
+
32
+ use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface;
33
+
34
+ class SimpleEnhancer implements RouteEnhancerInterface
35
+ {
36
+ }
37
+
38
+
39
+ Simply define services for your enhancers and tag them with ``dynamic_router_route_enhancer `` to have
40
+ them added to the routing. You can specify an optional ``priority `` parameter
41
+ on the tag to control the order in which enhancers are executed. The higher the
42
+ priority, the earlier the enhancer is executed.
43
+
44
+ .. configuration-block ::
45
+
46
+ .. code-block :: yaml
47
+
48
+ services :
49
+ app.routing.enhancer.simple :
50
+ class : AppBundle\Routing\Enhancer\SimpleEnhancer
51
+ tags :
52
+ - { name: dynamic_router_route_enhancer priority: 10 }
53
+
54
+ .. code-block :: xml
55
+
56
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
57
+ <container xmlns =" http://symfony.com/schema/dic/services"
58
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
59
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
60
+
61
+ <services >
62
+ <service id =" app.routing.enhancer.simple" class =" AppBundle\Routing\Enhancer\SimpleEnhancer" >
63
+ <tag name =" dynamic_router_route_enhancer" priority =" 10" />
64
+ </service >
65
+ </services >
66
+ </container >
67
+
68
+ .. code-block :: php
69
+
70
+ use Symfony\Component\DependencyInjection\Definition;
71
+
72
+ $definitionSendmail = new Definition('AppBundle\Routing\Enhancer\SimpleEnhancer');
73
+ $definitionSendmail->addTag('dynamic_router_route_enhancer',array('priority' => 10));
74
+ $container->setDefinition('app.routing.enhancer.simple', $definitionSendmail);
28
75
29
76
.. index :: Route Provider
77
+
30
78
.. _bundle-routing-custom_provider :
31
79
32
80
Using a Custom Route Provider
0 commit comments