Merge branch '2.8' into 3.2
* 2.8: [TwigBridge] Fix namespaced classes mix attr options between type-guess options and user options
This commit is contained in:
commit
c29714479a
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Twig\NodeVisitor;
|
||||
use Symfony\Bridge\Twig\Node\TransNode;
|
||||
use Symfony\Bridge\Twig\Node\TransDefaultDomainNode;
|
||||
use Twig\Environment;
|
||||
use Twig\Node\BlockNode;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\AssignNameExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
@ -21,6 +22,7 @@ use Twig\Node\Expression\FilterExpression;
|
||||
use Twig\Node\Expression\NameExpression;
|
||||
use Twig\Node\ModuleNode;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Node\SetNode;
|
||||
use Twig\NodeVisitor\AbstractNodeVisitor;
|
||||
|
||||
/**
|
||||
@ -48,7 +50,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
*/
|
||||
protected function doEnterNode(Node $node, Environment $env)
|
||||
{
|
||||
if ($node instanceof Node_Block || $node instanceof ModuleNode) {
|
||||
if ($node instanceof BlockNode || $node instanceof ModuleNode) {
|
||||
$this->scope = $this->scope->enter();
|
||||
}
|
||||
|
||||
@ -62,7 +64,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
$name = new AssignNameExpression($var, $node->getTemplateLine());
|
||||
$this->scope->set('domain', new NameExpression($var, $node->getTemplateLine()));
|
||||
|
||||
return new Node_Set(false, new Node(array($name)), new Node(array($node->getNode('expr'))), $node->getTemplateLine());
|
||||
return new SetNode(false, new Node(array($name)), new Node(array($node->getNode('expr'))), $node->getTemplateLine());
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +106,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($node instanceof Node_Block || $node instanceof ModuleNode) {
|
||||
if ($node instanceof BlockNode || $node instanceof ModuleNode) {
|
||||
$this->scope = $this->scope->leave();
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,13 @@ class FormFactory implements FormFactoryInterface
|
||||
|
||||
// user options may override guessed options
|
||||
if ($typeGuess) {
|
||||
$options = array_merge($typeGuess->getOptions(), $options);
|
||||
$attrs = array();
|
||||
$typeGuessOptions = $typeGuess->getOptions();
|
||||
if (isset($typeGuessOptions['attr']) && isset($options['attr'])) {
|
||||
$attrs = array('attr' => array_merge($typeGuessOptions['attr'], $options['attr']));
|
||||
}
|
||||
|
||||
$options = array_merge($typeGuessOptions, $options, $attrs);
|
||||
}
|
||||
|
||||
return $this->createNamedBuilder($property, $type, $data, $options);
|
||||
|
@ -316,7 +316,7 @@ class FormFactoryTest extends TestCase
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new TypeGuess(
|
||||
'Symfony\Component\Form\Extension\Core\Type\TextType',
|
||||
array('attr' => array('maxlength' => 10)),
|
||||
array('attr' => array('class' => 'foo', 'maxlength' => 10)),
|
||||
Guess::MEDIUM_CONFIDENCE
|
||||
)));
|
||||
|
||||
@ -324,7 +324,7 @@ class FormFactoryTest extends TestCase
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('maxlength' => 11)))
|
||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('class' => 'foo', 'maxlength' => 11)))
|
||||
->will($this->returnValue('builderInstance'));
|
||||
|
||||
$this->builder = $factory->createBuilderForProperty(
|
||||
|
Reference in New Issue
Block a user