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

Commit 292f2af

Browse files
committed
Further improved f2401a7
1 parent 348432d commit 292f2af

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

bundles/routing_auto/customization.rst

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ The goal of a ``PathProvider`` class is to add one or several path elements to
1313
the route stack. For example, the following provider will add the path
1414
``foo/bar`` to the route stack::
1515

16-
<?php
16+
// src/Acme/CmsBundle/RoutingAuto/PathProvider/FoobarProvider.php
17+
namespace Acme\CmsBundle\RoutingAuto\PathProvider;
1718

1819
use Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\PathProviderInterface;
1920
use Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\RouteStack;
@@ -33,35 +34,35 @@ To use the path provider you must register it in the container and add the
3334

3435
.. code-block:: yaml
3536
36-
# app/config/config.yml
3737
services:
38-
my_cms_bundle.path_provider.foobar:
39-
class: "FoobarProvider"
38+
acme_cms.path_provider.foobar:
39+
class: Acme\CmsBundle\RoutingAuto\PathProvider\FoobarProvider
4040
scope: prototype
4141
tags:
4242
- { name: cmf_routing_auto.provider, alias: "foobar"}
4343
4444
.. code-block:: xml
4545
46-
<!-- app/config/config.xml -->
47-
<service
48-
id="my_cms_bundle.path_provider.foobar"
49-
class="FoobarProvider"
50-
scope="prototype"
51-
>
52-
<tag name="cmf_routing_auto.provider" alias="foobar"/>
53-
</service>
46+
<?xml version="1.0" encoding="UTF-8" ?>
47+
<container xmlns="http://symfony.com/schema/dic/services">
48+
<service
49+
id="acme_cms.path_provider.foobar"
50+
class="Acme\CmsBundle\RoutingAuto\PathProvider\FoobarProvider"
51+
scope="prototype"
52+
>
53+
<tag name="cmf_routing_auto.provider" alias="foobar"/>
54+
</service>
55+
</container>
5456
5557
.. code-block:: php
5658
57-
// app/config/config.php
5859
use Symfony\Component\DependencyInjection\Definition;
5960
60-
$definition = new Definition('FooBarProvider');
61+
$definition = new Definition('Acme\CmsBundle\RoutingAuto\PathProvider\FoobarProvider');
6162
$definition->addTag('cmf_routing_auto.provider', array('alias' => 'foobar'));
6263
$definition->setScope('prototype');
6364
64-
$container->setDefinition('my_cms_bundle.path_provider.foobar', $definition);
65+
$container->setDefinition('acme_cms.path_provider.foobar', $definition);
6566
6667
The ``FoobarProvider`` is now available as **foobar** in the routing auto
6768
configuration.
@@ -84,7 +85,7 @@ registering your new class correctly in the DI configuration.
8485
This is a very simple implementation from the bundle - it is used to throw an
8586
exception when a path already exists::
8687

87-
namespace Acme\MainBundle\RoutingAuto\PathNotExists;
88+
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\RoutingAuto\PathNotExists;
8889

8990
use Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\PathActionInterface;
9091
use Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\Exception\CouldNotFindRouteException;
@@ -111,35 +112,35 @@ It is registered in the DI configuration as follows:
111112

112113
.. code-block:: yaml
113114
114-
# app/config/config.xml
115115
services:
116-
cmf_routing_auto.not_exists_action.throw_exception
117-
class: "My\Cms\AutoRoute\PathNotExists\ThrowException"
116+
cmf_routing_auto.not_exists_action.throw_exception:
117+
class: Symfony\Cmf\Bundle\RoutingAutoBundle\RoutingAuto\PathNotExists\ThrowException
118118
scope: prototype
119119
tags:
120120
- { name: cmf_routing_auto.provider, alias: "throw_exception"}
121121
122122
.. code-block:: xml
123123
124-
<!-- app/config/config.xml -->
125-
<service
126-
id="my_cms.not_exists_action.throw_exception"
127-
class="My\Cms\AutoRoute\PathNotExists\ThrowException"
128-
scope="prototype"
129-
>
130-
<tag name="cmf_routing_auto.not_exists_action" alias="throw_exception"/>
131-
</service>
124+
<?xml version="1.0" encoding="UTF-8" ?>
125+
<container xmlns="http://symfony.com/schema/dic/services">
126+
<service
127+
id="cmf_routing_auto.not_exists_action.throw_exception"
128+
class="Symfony\Cmf\Bundle\RoutingAutoBundle\RoutingAuto\PathNotExists\ThrowException"
129+
scope="prototype"
130+
>
131+
<tag name="cmf_routing_auto.not_exists_action" alias="throw_exception"/>
132+
</service>
133+
</container>
132134
133135
.. code-block:: php
134136
135-
// app/config/config.php
136137
use Symfony\Component\DependencyInjection\Definition;
137138
138-
$definition = new Definition('My\Cms\AutoRoute\PathNotExists\ThrowException');
139+
$definition = new Definition('Symfony\Cmf\Bundle\RoutingAutoBundle\RoutingAuto\PathNotExists\ThrowException');
139140
$definition->addTag('cmf_routing_auto.provider', array('alias' => 'throw_exception'));
140141
$definition->setScope('prototype');
141142
142-
$container->setDefinition('my_cms.some_bundle.path_provider.throw_exception', $definition);
143+
$container->setDefinition('cmf_routing_auto.not_exists_action.throw_exception', $definition);
143144
144145
Note the following:
145146

0 commit comments

Comments
 (0)