Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bcf0e91

Browse files
committed
feature #17690 [FrameworkBundle] Use canBeEnabled() instead of canBeUnset() for consistency (Ener-Getick)
This PR was squashed before being merged into the 3.1-dev branch (closes #17690). Discussion ---------- [FrameworkBundle] Use canBeEnabled() instead of canBeUnset() for consistency | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #13703 | License | MIT I'm not sure if we should consider this as a bug fix or as a new feature. Commits ------- 39723c5 [FrameworkBundle] Use canBeEnabled() instead of canBeUnset() for consistency
2 parents d131828 + 39723c5 commit bcf0e91

File tree

3 files changed

+56
-14
lines changed

3 files changed

+56
-14
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private function addProfilerSection(ArrayNodeDefinition $rootNode)
204204
->booleanNode('only_master_requests')->defaultFalse()->end()
205205
->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end()
206206
->arrayNode('matcher')
207-
->canBeUnset()
207+
->canBeEnabled()
208208
->performNoDeepMerging()
209209
->fixXmlConfig('ip')
210210
->children()
@@ -231,7 +231,7 @@ private function addRouterSection(ArrayNodeDefinition $rootNode)
231231
->children()
232232
->arrayNode('router')
233233
->info('router configuration')
234-
->canBeUnset()
234+
->canBeEnabled()
235235
->children()
236236
->scalarNode('resource')->isRequired()->end()
237237
->scalarNode('type')->end()
@@ -258,7 +258,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
258258
->children()
259259
->arrayNode('session')
260260
->info('session configuration')
261-
->canBeUnset()
261+
->canBeEnabled()
262262
->children()
263263
->scalarNode('storage_id')->defaultValue('session.storage.native')->end()
264264
->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end()
@@ -289,7 +289,7 @@ private function addRequestSection(ArrayNodeDefinition $rootNode)
289289
->children()
290290
->arrayNode('request')
291291
->info('request configuration')
292-
->canBeUnset()
292+
->canBeEnabled()
293293
->fixXmlConfig('format')
294294
->children()
295295
->arrayNode('formats')
@@ -318,7 +318,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
318318
->children()
319319
->arrayNode('templating')
320320
->info('templating configuration')
321-
->canBeUnset()
321+
->canBeEnabled()
322322
->children()
323323
->scalarNode('hinclude_default_template')->defaultNull()->end()
324324
->scalarNode('cache')->end()
@@ -373,7 +373,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
373373
->children()
374374
->arrayNode('assets')
375375
->info('assets configuration')
376-
->canBeUnset()
376+
->canBeEnabled()
377377
->fixXmlConfig('base_url')
378378
->children()
379379
->scalarNode('version_strategy')->defaultNull()->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ public function load(array $configs, ContainerBuilder $container)
8787
$loader->load('test.xml');
8888
}
8989

90-
if (isset($config['session'])) {
90+
if ($this->isConfigEnabled($container, $config['session'])) {
9191
$this->sessionConfigEnabled = true;
9292
$this->registerSessionConfiguration($config['session'], $container, $loader);
9393
}
9494

95-
if (isset($config['request'])) {
95+
if ($this->isConfigEnabled($container, $config['request'])) {
9696
$this->registerRequestConfiguration($config['request'], $container, $loader);
9797
}
9898

@@ -108,11 +108,11 @@ public function load(array $configs, ContainerBuilder $container)
108108

109109
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
110110

111-
if (isset($config['assets'])) {
111+
if ($this->isConfigEnabled($container, $config['assets'])) {
112112
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
113113
}
114114

115-
if (isset($config['templating'])) {
115+
if ($this->isConfigEnabled($container, $config['templating'])) {
116116
$this->registerTemplatingConfiguration($config['templating'], $config['ide'], $container, $loader);
117117
}
118118

@@ -123,7 +123,7 @@ public function load(array $configs, ContainerBuilder $container)
123123
$this->registerTranslatorConfiguration($config['translator'], $container);
124124
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);
125125

126-
if (isset($config['router'])) {
126+
if ($this->isConfigEnabled($container, $config['router'])) {
127127
$this->registerRouterConfiguration($config['router'], $container, $loader);
128128
}
129129

@@ -313,7 +313,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
313313

314314
$container->setParameter('profiler.storage.dsn', $config['dsn']);
315315

316-
if (isset($config['matcher'])) {
316+
if ($this->isConfigEnabled($container, $config['matcher'])) {
317317
if (isset($config['matcher']['service'])) {
318318
$container->setAlias('profiler.request_matcher', $config['matcher']['service']);
319319
} elseif (isset($config['matcher']['ip']) || isset($config['matcher']['path']) || isset($config['matcher']['ips'])) {
@@ -899,7 +899,7 @@ private function registerSecurityCsrfConfiguration(array $config, ContainerBuild
899899
*/
900900
private function registerSerializerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
901901
{
902-
if (!$config['enabled']) {
902+
if (!$this->isConfigEnabled($container, $config)) {
903903
return;
904904
}
905905

@@ -1004,7 +1004,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
10041004
*/
10051005
private function registerPropertyInfoConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
10061006
{
1007-
if (!$config['enabled']) {
1007+
if (!$this->isConfigEnabled($container, $config)) {
10081008
return;
10091009
}
10101010

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function testAssetsCanBeEnabled()
108108
$config = $processor->processConfiguration($configuration, array(array('assets' => null)));
109109

110110
$defaultConfig = array(
111+
'enabled' => true,
111112
'version_strategy' => null,
112113
'version' => null,
113114
'version_format' => '%%s?%%s',
@@ -193,6 +194,10 @@ protected static function getBundleDefaultConfig()
193194
'only_master_requests' => false,
194195
'dsn' => 'file:%kernel.cache_dir%/profiler',
195196
'collect' => true,
197+
'matcher' => array(
198+
'enabled' => false,
199+
'ips' => array(),
200+
),
196201
),
197202
'translator' => array(
198203
'enabled' => false,
@@ -223,6 +228,43 @@ protected static function getBundleDefaultConfig()
223228
'property_info' => array(
224229
'enabled' => false,
225230
),
231+
'router' => array(
232+
'enabled' => false,
233+
'http_port' => 80,
234+
'https_port' => 443,
235+
'strict_requirements' => true,
236+
),
237+
'session' => array(
238+
'enabled' => false,
239+
'storage_id' => 'session.storage.native',
240+
'handler_id' => 'session.handler.native_file',
241+
'cookie_httponly' => true,
242+
'gc_probability' => 1,
243+
'save_path' => '%kernel.cache_dir%/sessions',
244+
'metadata_update_threshold' => '0',
245+
),
246+
'request' => array(
247+
'enabled' => false,
248+
'formats' => array(),
249+
),
250+
'templating' => array(
251+
'enabled' => false,
252+
'hinclude_default_template' => null,
253+
'form' => array(
254+
'resources' => array('FrameworkBundle:Form'),
255+
),
256+
'engines' => array(),
257+
'loaders' => array(),
258+
),
259+
'assets' => array(
260+
'enabled' => false,
261+
'version_strategy' => null,
262+
'version' => null,
263+
'version_format' => '%%s?%%s',
264+
'base_path' => '',
265+
'base_urls' => array(),
266+
'packages' => array(),
267+
),
226268
);
227269
}
228270
}

0 commit comments

Comments
 (0)