8000 bug #15428 Fix the validation of form resources to register the defau… · symfony/symfony@051cb35 · GitHub
[go: up one dir, main page]

Skip to content

Commit 051cb35

Browse files
committed
bug #15428 Fix the validation of form resources to register the default theme (stof)
This PR was merged into the 2.3 branch. Discussion ---------- Fix the validation of form resources to register the default theme | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a #14173 made some wrong changes, changing the behavior of the code. This reverts to the right behavior in affected places Commits ------- ea92610 Fix the validation of form resources to register the default theme
2 parents bdfc9dc + ea92610 commit 051cb35

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
260260
->addDefaultChildrenIfNoneSet()
261261
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
262262
->validate()
263-
->ifNotInArray(array('FrameworkBundle:Form'))
263+
->ifTrue(function ($v) {return !in_array('FrameworkBundle:Form', $v); })
264264
->then(function ($v) {
265265
return array_merge(array('FrameworkBundle:Form'), $v);
266266
})

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ public function testDefaultConfig()
2727
);
2828
}
2929

30+
public function testDoNoDuplicateDefaultFormResources()
31+
{
32+
$input = array('templating' => array(
33+
'form' => array('resources' => array('FrameworkBundle:Form')),
34+
'engines' => array('php'),
35+
));
36+
37+
$processor = new Processor();
38+
$config = $processor->processConfiguration(new Configuration(), array($input));
39+
40+
$this->assertEquals(array('FrameworkBundle:Form'), $config['templating']['form']['resources']);
41+
}
42+
3043
/**
3144
* @dataProvider getTestValidTrustedProxiesData
3245
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private function addFormSection(ArrayNodeDefinition $rootNode)
5858
->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()
5959
->example(array('MyBundle::form.html.twig'))
6060
->validate()
61-
->ifNotInArray(array('form_div_layout.html.twig'))
61+
->ifTrue(function ($v) {return !in_array('form_div_layout.html.twig', $v); })
6262
->then(function ($v) {
6363
return array_merge(array('form_div_layout.html.twig'), $v);
6464
})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection;
13+
14+
use Symfony\Bundle\TwigBundle\DependencyInjection\Configuration;
15+
use Symfony\Component\Config\Definition\Processor;
16+
17+
class ConfigurationTest extends \PHPUnit_Framework_TestCase
18+
{
19+
public function testDoNoDuplicateDefaultFormResources()
20+
{
21+
$input = array(
22+
'form' => array('resources' => array('form_div_layout.html.twig')),
23+
);
24+
25+
$processor = new Processor();
26+
$config = $processor->processConfiguration(new Configuration(), array($input));
27+
28+
$this->assertEquals(array('form_div_layout.html.twig'), $config['form']['resources']);
29+
}
30+
}

0 commit comments

Comments
 (0)
0