8000 [FrameworkBundle] Use canBeEnabled() instead of canBeUnset() for consistency by GuilhemN · Pull Request #17690 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Use canBeEnabled() instead of canBeUnset() for consistency #17690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10000
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private function addProfilerSection(ArrayNodeDefinition $rootNode)
->booleanNode('only_master_requests')->defaultFalse()->end()
->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end()
->arrayNode('matcher')
->canBeUnset()
->canBeEnabled()
->performNoDeepMerging()
->fixXmlConfig('ip')
->children()
Expand All @@ -231,7 +231,7 @@ private function addRouterSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('router')
->info('router configuration')
->canBeUnset()
->canBeEnabled()
->children()
->scalarNode('resource')->isRequired()->end()
->scalarNode('type')->end()
Expand All @@ -258,7 +258,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('session')
->info('session configuration')
->canBeUnset()
->canBeEnabled()
->children()
->scalarNode('storage_id')->defaultValue('session.storage.native')->end()
->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end()
Expand Down Expand Up @@ -289,7 +289,7 @@ private function addRequestSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('request')
->info('request configuration')
->canBeUnset()
->canBeEnabled()
->fixXmlConfig('format')
->children()
->arrayNode('formats')
Expand Down Expand Up @@ -318,7 +318,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('templating')
->info('templating configuration')
->canBeUnset()
->canBeEnabled()
->children()
->scalarNode('hinclude_default_template')->defaultNull()->end()
->scalarNode('cache')->end()
Expand Down Expand Up @@ -373,7 +373,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('assets')
->info('assets configuration')
->canBeUnset()
->canBeEnabled()
->fixXmlConfig('base_url')
->children()
->scalarNode('version_strategy')->defaultNull()->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('test.xml');
}

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

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

Expand All @@ -104,11 +104,11 @@ public function load(array $configs, ContainerBuilder $container)

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

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

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

Expand All @@ -119,7 +119,7 @@ public function load(array $configs, ContainerBuilder $container)
$this->registerTranslatorConfiguration($config['translator'], $container);
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);

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

Expand Down Expand Up @@ -309,7 +309,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $

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

if (isset($config['matcher'])) {
if ($this->isConfigEnabled($container, $config['matcher'])) {
if (isset($config['matcher']['service'])) {
$container->setAlias('profiler.request_matcher', $config['matcher']['service']);
} elseif (isset($config['matcher']['ip']) || isset($config['matcher']['path']) || isset($config['matcher']['ips'])) {
Expand Down Expand Up @@ -890,7 +890,7 @@ private function registerSecurityCsrfConfiguration(array $config, ContainerBuild
*/
private function registerSerializerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
if (!$config['enabled']) {
if (!$this->isConfigEnabled($container, $config)) {
return;
}

Expand Down Expand Up @@ -974,7 +974,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
*/
private function registerPropertyInfoConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
if (!$config['enabled']) {
if (!$this->isConfigEnabled($container, $config)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function testAssetsCanBeEnabled()
$config = $processor->processConfiguration($configuration, array(array('assets' => null)));

$defaultConfig = array(
'enabled' => true,
'version_strategy' => null,
'version' => null,
'version_format' => '%%s?%%s',
Expand Down Expand Up @@ -193,6 +194,10 @@ protected static function getBundleDefaultConfig()
'only_master_requests' => false,
'dsn' => 'file:%kernel.cache_dir%/profiler',
'collect' => true,
'matcher' => array(
'enabled' => false,
'ips' => array(),
),
),
'translator' => array(
'enabled' => false,
Expand Down Expand Up @@ -223,6 +228,43 @@ protected static function getBundleDefaultConfig()
'property_info' => array(
'enabled' => false,
),
'router' => array(
'enabled' => false,
'http_port' => 80,
'https_port' => 443,
'strict_requirements' => true,
),
'session' => array(
'enabled' => false,
'storage_id' => 'session.storage.native',
'handler_id' => 'session.handler.native_file',
'cookie_httponly' => true,
'gc_probability' => 1,
'save_path' => '%kernel.cache_dir%/sessions',
'metadata_update_threshold' => '0',
),
'request' => array(
'enabled' => false,
'formats' => array(),
),
'templating' => array(
'enabled' => false,
'hinclude_default_template' => null,
'form' => array(
'resources' => array('FrameworkBundle:Form'),
),
'engines' => array(),
'loaders' => array(),
),
'assets' => array(
'enabled' => false,
'version_strategy' => null,
'version' => null,
'version_format' => '%%s?%%s',
'base_path' => '',
'base_urls' => array(),
'packages' => array(),
),
);
}
}
0