8000 minor #13349 [2.7] Fix deprecations on TwigBundle and FrameworkBundle… · symfony/symfony@545e1a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 545e1a4

Browse files
committed
minor #13349 [2.7] Fix deprecations on TwigBundle and FrameworkBundle semantic configurations (hhamon)
This PR was merged into the 2.7 branch. Discussion ---------- [2.7] Fix deprecations on TwigBundle and FrameworkBundle semantic configurations | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Commits ------- 8d60396 [FrameworkBundle|TwigBundle] update functional tests configuration files to not use deprecated config keys anymore.
2 parents 7a4c5fc + 8d60396 commit 545e1a4

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ public function getConfigTreeBuilder()
4343
$rootNode = $treeBuilder->root('framework');
4444

4545
$rootNode
46+
// Check deprecations before the config is processed to ensure
47+
// the setting has been explicitly defined in a configuration file.
48+
->beforeNormalization()
49+
->ifTrue(function ($v) { return isset($v['csrf_protection']['field_name']); })
50+
->then(function ($v) {
51+
trigger_error('The framework.csrf_protection.field_name configuration key is deprecated since version 2.4 and will be removed in 3.0. Use the framework.form.csrf_protection.field_name configuration key instead', E_USER_DEPRECATED);
52+
53+
return $v;
54+
})
55+
->end()
4656
->children()
4757
->scalarNode('secret')->end()
4858
->scalarNode('http_method_override')

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ private function registerFormConfiguration($config, ContainerBuilder $container,
205205
if (null !== $config['form']['csrf_protection']['field_name']) {
206206
$container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']);
207207
} else {
208-
trigger_error('The framework.csrf_protection.field_name configuration key is deprecated since version 2.4 and will be removed in 3.0. Use the framework.form.csrf_protection.field_name configuration key instead', E_USER_DEPRECATED);
209208
$container->setParameter('form.type_extension.csrf.field_name', $config['csrf_protection']['field_name']);
210209
}
211210
} else {

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
<?php
22

33
$container->loadFromExtension('framework', array(
4-
'csrf_protection' => array(
5-
'enabled' => false,
6-
),
4+
'csrf_protection' => true,
75
'form' => array(
86
'enabled' => true,
9-
'csrf_protection' => array(
10-
'enabled' => true,
11-
),
7+
'csrf_protection' => true,
128
),
139
'session' => array(
1410
'handler_id' => null,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public function testLegacyFormCsrfFieldNameCanBeSetUnderCsrfSettings()
467467
$this->assertEquals('_custom', $container->getParameter('form.type_extension.csrf.field_name'));
468468
}
469469

470-
public function testFormCsrfFieldNameUnderFormSettingsTakesPrecedence()
470+
public function testLegacyFormCsrfFieldNameUnderFormSettingsTakesPrecedence()
471471
{
472472
$container = $this->createContainerFromFile('form_csrf_under_form_sets_field_name');
473473

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,21 @@ public function getConfigTreeBuilder()
4949
private function addFormSection(ArrayNodeDefinition $rootNode)
5050
{
5151
$rootNode
52+
// Check deprecation before the config is processed to ensure
53+
// the setting has been explicitly defined in a configuration file.
54+
->beforeNormalization()
55+
->ifTrue(function ($v) { return isset($v['form']['resources']); })
56+
->then(function ($v) {
57+
trigger_error('The twig.form.resources configuration key is deprecated since version 2.6 and will be removed in 3.0. Use the twig.form_themes configuration key instead.', E_USER_DEPRECATED);
58+
59+
return $v;
60+
})
61+
->end()
5262
->validate()
5363
->ifTrue(function ($v) {
5464
return count($v['form']['resources']) > 0;
5565
})
5666
->then(function ($v) {
57-
trigger_error('The twig.form.resources configuration key is deprecated since version 2.6 and will be removed in 3.0. Use the twig.form_themes configuration key instead.', E_USER_DEPRECATED);
58-
5967
$v['form_themes'] = array_values(array_unique(array_merge($v['form']['resources'], $v['form_themes'])));
6068

6169
return $v;

0 commit comments

Comments
 (0)
0