8000 Merge branch '2.7' into 2.8 · symfony/symfony@419556f · GitHub
[go: up one dir, main page]

Skip to content

Commit 419556f

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [TwigBridge] Fix namespaced classes mix attr options between type-guess options and user options
2 parents 0057459 + 658236b commit 419556f

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
use Symfony\Bridge\Twig\Node\TransNode;
1515
use Symfony\Bridge\Twig\Node\TransDefaultDomainNode;
1616
use Twig\Environment;
17+
use Twig\Node\BlockNode;
1718
use Twig\Node\Expression\ArrayExpression;
1819
use Twig\Node\Expression\AssignNameExpression;
1920
use Twig\Node\Expression\ConstantExpression;
2021
use Twig\Node\Expression\FilterExpression;
2122
use Twig\Node\Expression\NameExpression;
2223
use Twig\Node\ModuleNode;
2324
use Twig\Node\Node;
25+
use Twig\Node\SetNode;
2426
use Twig\NodeVisitor\AbstractNodeVisitor;
2527

2628
/**
@@ -48,7 +50,7 @@ public function __construct()
4850
*/
4951
protected function doEnterNode(Node $node, Environment $env)
5052
{
51-
if ($node instanceof Node_Block || $node instanceof ModuleNode) {
53+
if ($node instanceof BlockNode || $node instanceof ModuleNode) {
5254
$this->scope = $this->scope->enter();
5355
}
5456

@@ -62,7 +64,7 @@ protected function doEnterNode(Node $node, Environment $env)
6264
$name = new AssignNameExpression($var, $node->getTemplateLine());
6365
$this->scope->set('domain', new NameExpression($var, $node->getTemplateLine()));
6466

65-
return new Node_Set(false, new Node(array($name)), new Node(array($node->getNode('expr'))), $node->getTemplateLine());
67+
return new SetNode(false, new Node(array($name)), new Node(array($node->getNode('expr'))), $node->getTemplateLine());
6668
}
6769
}
6870

@@ -104,7 +106,7 @@ protected function doLeaveNode(Node $node, Environment $env)
104106
return false;
105107
}
106108

107-
if ($node instanceof Node_Block || $node instanceof ModuleNode) {
109+
if ($node instanceof BlockNode || $node instanceof ModuleNode) {
108110
$this->scope = $this->scope->leave();
109111
}
110112

src/Symfony/Component/Form/FormFactory.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,13 @@ public function createBuilderForProperty($class, $property, $data = null, array
153153

154154
// user options may override guessed options
155155
if ($typeGuess) {
156-
$options = array_merge($typeGuess->getOptions(), $options);
156+
$attrs = array();
157+
$typeGuessOptions = $typeGuess->getOptions();
158+
if (isset($typeGuessOptions['attr']) && isset($options['attr'])) {
159+
$attrs = array('attr' => array_merge($typeGuessOptions['attr'], $options['attr']));
160+
}
161+
162+
$options = array_merge($typeGuessOptions, $options, $attrs);
157163
}
158164

159165
return $this->createNamedBuilder($property, $type, $data, $options);

src/Symfony/Component/Form/Tests/FormFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,15 +686,15 @@ public function testOptionsCanBeOverridden()
686686
->with('Application\Author', 'firstName')
687687
->will($this->returnValue(new TypeGuess(
688688
'Symfony\Component\Form\Extension\Core\Type\TextType',
689-
array('attr' => array('maxlength' => 10)),
689+
array('attr' => array('class' => 'foo', 'maxlength' => 10)),
690690
Guess::MEDIUM_CONFIDENCE
691691
)));
692692

693693
$factory = $this->getMockFactory(array('createNamedBuilder'));
694694

695695
$factory->expects($this->once())
696696
->method('createNamedBuilder')
697-
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('maxlength' => 11)))
697+
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('class' => 'foo', 'maxlength' => 11)))
698698
->will($this->returnValue('builderInstance'));
699699

700700
$this->builder = $factory->createBuilderForProperty(

0 commit comments

Comments
 (0)
0