Skip to content

Commit 31d61e5

Browse files
committed
Changed enabling node
1 parent bce67f4 commit 31d61e5

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

DependencyInjection/CmfRoutingExtension.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function load(array $configs, ContainerBuilder $container)
2525
$config = $this->processConfiguration(new Configuration(), $configs);
2626
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
2727

28-
if (!empty($config['dynamic']['enabled'])) {
28+
if ($config['dynamic']['enabled']) {
2929
// load this even if no explicit enabled value but some configuration
3030
$this->setupDynamicRouter($config['dynamic'], $container, $loader);
3131
}
@@ -88,13 +88,17 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
8888

8989
$hasProvider = false;
9090
$hasContentRepository = false;
91-
if (!empty($config['persistence']['phpcr']['enabled'])) {
91+
if ($config['persistence']['phpcr']['enabled'] && $config['persistence']['orm']['enabled']) {
92+
throw new InvalidConfigurationException('You can only enable either phpcr or orm, not both.');
93+
}
94+
95+
if ($config['persistence']['phpcr']['enabled']) {
9296
$this->loadPhpcrProvider($config['persistence']['phpcr'], $loader, $container, $locales);
9397
$hasProvider = true;
9498
$hasContentRepository = true;
9599
}
96100

97-
if (!empty($config['persistence']['orm']['enabled'])) {
101+
if ($config['persistence']['orm']['enabled']) {
98102
$this->loadOrmProvider($config['persistence']['orm'], $loader, $container);
99103
$hasProvider = true;
100104
}

DependencyInjection/Configuration.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ public function getConfigTreeBuilder()
4343
->fixXmlConfig('template_by_class', 'templates_by_class')
4444
->fixXmlConfig('route_filter_by_id', 'route_filters_by_id')
4545
->fixXmlConfig('locale')
46+
->addDefaultsIfNotSet()
4647
->children()
47-
->scalarNode('enabled')->defaultNull()->end()
48+
->booleanNode('enabled')->defaultFalse()->end()
4849
->scalarNode('generic_controller')->defaultNull()->end()
4950
->arrayNode('controllers_by_type')
5051
->useAttributeAsKey('type')
@@ -61,8 +62,9 @@ public function getConfigTreeBuilder()
6162
->arrayNode('persistence')
6263
->children()
6364
->arrayNode('phpcr')
65+
->addDefaultsIfNotSet()
6466
->children()
65-
->scalarNode('enabled')->defaultNull()->end()
67+
->booleanNode('enabled')->defaultFalse()->end()
6668
->scalarNode('manager_name')->defaultNull()->end()
6769
->scalarNode('route_basepath')->defaultValue('/cms/routes')->end()
6870
->scalarNode('content_basepath')->defaultValue('/cms/content')->end()
@@ -73,8 +75,9 @@ public function getConfigTreeBuilder()
7375
->end()
7476
->end()
7577
->arrayNode('orm')
78+
->addDefaultsIfNotSet()
7679
->children()
77-
->scalarNode('enabled')->defaultNull()->end()
80+
->booleanNode('enabled')->defaultFalse()->end()
7881
->scalarNode('manager_name')->defaultNull()->end()
7982
->end()
8083
->end()

0 commit comments

Comments
 (0)