Skip to content

Commit 190af41

Browse files
committed
Merge pull request #173 from symfony-cmf/cleanup_enhancers
make enhancer services private
2 parents 55be9d5 + 5728dcc commit 190af41

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

DependencyInjection/CmfRoutingExtension.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection;
44

5-
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
5+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
66
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
8+
use Symfony\Component\DependencyInjection\Reference;
9+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
710
use Symfony\Component\Config\FileLocator;
811
use Symfony\Component\Config\Definition\Processor;
9-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
10-
use Symfony\Component\DependencyInjection\Reference;
1112
use Symfony\Component\Config\Loader\LoaderInterface;
12-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1313

1414
/**
1515
* @author Philippo de Santis
@@ -144,13 +144,12 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
144144
foreach ($config['templates_by_class'] as $key => $value) {
145145
$controllerForTemplates[$key] = $config['generic_controller'];
146146
}
147-
$container->setParameter($this->getAlias() . '.defined_templates_class', $controllerForTemplates);
147+
148+
$definition = $container->getDefinition($this->getAlias() . '.enhancer_controller_for_templates_by_class');
149+
$definition->replaceArgument(2, $controllerForTemplates);
150+
148151
$dynamic->addMethodCall('addRouteEnhancer', array(new Reference($this->getAlias() . '.enhancer_controller_for_templates_by_class')));
149-
} else {
150-
$container->removeDefinition($this->getAlias() . '.enhancer_controller_for_templates_by_class');
151152
}
152-
} else {
153-
$container->removeDefinition($this->getAlias() . '.enhancer_controller_for_templates_by_class');
154153
}
155154

156155
if (!empty($config['route_filters_by_id'])) {

Resources/config/routing-dynamic.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@
1919
</parameters>
2020

2121
<services>
22-
2322
<service id="cmf_routing.enhancer_route_content" class="%cmf_routing.enhancer_route_content_class%">
2423
<argument>_route_object</argument>
2524
<argument>_content</argument>
2625
</service>
27-
<service id="cmf_routing.enhancer_explicit_template" class="%cmf_routing.enhancer_explicit_template_class%">
26+
27+
<service id="cmf_routing.enhancer_explicit_template" class="%cmf_routing.enhancer_explicit_template_class%" public="false">
2828
<argument>_template</argument>
2929
<argument>_controller</argument>
3030
<argument>%cmf_routing.generic_controller%</argument>
3131
</service>
32-
<service id="cmf_routing.enhancer_controllers_by_type" class="%cmf_routing.enhancer_controllers_by_type_class%">
32+
<service id="cmf_routing.enhancer_controllers_by_type" class="%cmf_routing.enhancer_controllers_by_type_class%" public="false">
3333
<argument>type</argument>
3434
<argument>_controller</argument>
3535
<argument>%cmf_routing.controllers_by_type%</argument>
3636
</service>
37-
<service id="cmf_routing.enhancer_controllers_by_class" class="%cmf_routing.enhancer_field_by_class_class%">
37+
<service id="cmf_routing.enhancer_controllers_by_class" class="%cmf_routing.enhancer_field_by_class_class%" public="false">
3838
<argument>_content</argument>
3939
<argument>_controller</argument>
4040
<argument>%cmf_routing.controllers_by_class%</argument>
4141
</service>
42-
<service id="cmf_routing.enhancer_controller_for_templates_by_class" class="%cmf_routing.enhancer_field_by_class_class%">
42+
<service id="cmf_routing.enhancer_controller_for_templates_by_class" class="%cmf_routing.enhancer_field_by_class_class%" public="false">
4343
<argument>_content</argument>
4444
<argument>_controller</argument>
45-
<argument>%cmf_routing.defined_templates_class%</argument>
45+
<argument type="collection" />
4646
</service>
47-
<service id="cmf_routing.enhancer_templates_by_class" class="%cmf_routing.enhancer_field_by_class_class%">
47+
<service id="cmf_routing.enhancer_templates_by_class" class="%cmf_routing.enhancer_field_by_class_class%" public="false">
4848
<argument>_content</argument>
4949
<argument>_template</argument>
5050
<argument>%cmf_routing.templates_by_class%</argument>

0 commit comments

Comments
 (0)