8000 [2.7] Fix deprecations on TwigBundle and FrameworkBundle semantic configurations by hhamon · Pull Request #13349 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.7] Fix deprecations on TwigBundle and FrameworkBundle semantic configurations #13349

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

Merged
merged 1 commit into from
Jan 9, 2015
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ public function getConfigTreeBuilder()
$rootNode = $treeBuilder->root('framework');

$rootNode
// Check deprecations before the config is processed to ensure
// the setting has been explicitly defined in a configuration file.
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['csrf_protection']['field_name']); })
->then(function ($v) {
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);

return $v;
})
->end()
->children()
->scalarNode('secret')->end()
->scalarNode('http_method_override')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ private function registerFormConfiguration($config, ContainerBuilder $container,
if (null !== $config['form']['csrf_protection']['field_name']) {
$container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']);
} else {
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);
$container->setParameter('form.type_extension.csrf.field_name', $config['csrf_protection']['field_name']);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php

$container->loadFromExtension('framework', array(
'csrf_protection' => array(
'enabled' => false,
),
'csrf_protection' => true,
'form' => array(
'enabled' => true,
'csrf_protection' => array(
'enabled' => true,
),
'csrf_protection' => true,
),
'session' => array(
'handler_id' => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public function testLegacyFormCsrfFieldNameCanBeSetUnderCsrfSettings()
$this->assertEquals('_custom', $container->getParameter('form.type_extension.csrf.field_name'));
}

public function testFormCsrfFieldNameUnderFormSettingsTakesPrecedence()
public function testLegacyFormCsrfFieldNameUnderFormSettingsTakesPrecedence()
{
$container = $this->createContainerFromFile('form_csrf_under_form_sets_field_name');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,21 @@ public function getConfigTreeBuilder()
private function addFormSection(ArrayNodeDefinition $rootNode)
{
$rootNode
// Check deprecation before the config is processed to ensure
// the setting has been explicitly defined in a configuration file.
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['form']['resources']); })
->then(function ($v) {
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);

return $v;
})
->end()
->validate()
->ifTrue(function ($v) {
return count($v['form']['resources']) > 0;
})
->then(function ($v) {
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);

$v['form_themes'] = array_values(array_unique(array_merge($v['form']['resources'], $v['form_themes'])));

return $v;
Expand Down
0