Merge branch '2.8' into 3.0
* 2.8: Fix merge [Process] Fix running tests on HHVM>=3.8 [Form] Improved performance of ChoiceType and its subtypes Removed an object as route generator argument Conflicts: src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
This commit is contained in:
commit
78a08f3a68
@ -30,7 +30,7 @@ services: mongodb
|
|||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- if [[ ! $deps && ! $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && $TRAVIS_PHP_VERSION != hhvm && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; fi;
|
- if [[ ! $deps && ! $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && $TRAVIS_PHP_VERSION != hhvm && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; fi;
|
||||||
- if [[ ! $deps && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi;
|
- if [[ ! $deps && $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi;
|
||||||
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi;
|
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi;
|
||||||
- echo memory_limit = -1 >> $INI_FILE
|
- echo memory_limit = -1 >> $INI_FILE
|
||||||
- echo session.gc_probability = 0 >> $INI_FILE
|
- echo session.gc_probability = 0 >> $INI_FILE
|
||||||
|
@ -111,7 +111,12 @@ abstract class DoctrineType extends AbstractType
|
|||||||
public function __construct(ManagerRegistry $registry, PropertyAccessorInterface $propertyAccessor = null, ChoiceListFactoryInterface $choiceListFactory = null)
|
public function __construct(ManagerRegistry $registry, PropertyAccessorInterface $propertyAccessor = null, ChoiceListFactoryInterface $choiceListFactory = null)
|
||||||
{
|
{
|
||||||
$this->registry = $registry;
|
$this->registry = $registry;
|
||||||
$this->choiceListFactory = $choiceListFactory ?: new PropertyAccessDecorator(new DefaultChoiceListFactory(), $propertyAccessor);
|
$this->choiceListFactory = $choiceListFactory ?: new CachingFactoryDecorator(
|
||||||
|
new PropertyAccessDecorator(
|
||||||
|
new DefaultChoiceListFactory(),
|
||||||
|
$propertyAccessor
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bridge\Doctrine\Form\Type;
|
namespace Symfony\Bridge\Doctrine\Form\Type;
|
||||||
|
|
||||||
use Doctrine\Common\Persistence\ObjectManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
use Doctrine\ORM\Query\Parameter;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
|
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
@ -78,8 +79,20 @@ class EntityType extends DoctrineType
|
|||||||
public function getQueryBuilderPartsForCachingHash($queryBuilder)
|
public function getQueryBuilderPartsForCachingHash($queryBuilder)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
$queryBuilder->getQuery()->getSQL(),
|
$queryBuilder->getQuery()->getSQL(),
|
||||||
$queryBuilder->getParameters()->toArray(),
|
array_map(array($this, 'parameterToArray'), $queryBuilder->getParameters()->toArray()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a query parameter to an array.
|
||||||
|
*
|
||||||
|
* @param Parameter $parameter The query parameter
|
||||||
|
*
|
||||||
|
* @return array The array representation of the parameter
|
||||||
|
*/
|
||||||
|
private function parameterToArray(Parameter $parameter)
|
||||||
|
{
|
||||||
|
return array($parameter->getName(), $parameter->getType(), $parameter->getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1127,6 +1127,69 @@ class EntityTypeTest extends TypeTestCase
|
|||||||
$this->assertSame($choiceLoader1, $choiceLoader3);
|
$this->assertSame($choiceLoader1, $choiceLoader3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLoaderCachingWithParameters()
|
||||||
|
{
|
||||||
|
$entity1 = new SingleIntIdEntity(1, 'Foo');
|
||||||
|
$entity2 = new SingleIntIdEntity(2, 'Bar');
|
||||||
|
$entity3 = new SingleIntIdEntity(3, 'Baz');
|
||||||
|
|
||||||
|
$this->persist(array($entity1, $entity2, $entity3));
|
||||||
|
|
||||||
|
$repo = $this->em->getRepository(self::SINGLE_IDENT_CLASS);
|
||||||
|
|
||||||
|
$entityType = new EntityType(
|
||||||
|
$this->emRegistry,
|
||||||
|
PropertyAccess::createPropertyAccessor()
|
||||||
|
);
|
||||||
|
|
||||||
|
$entityTypeGuesser = new DoctrineOrmTypeGuesser($this->emRegistry);
|
||||||
|
|
||||||
|
$factory = Forms::createFormFactoryBuilder()
|
||||||
|
->addType($entityType)
|
||||||
|
->addTypeGuesser($entityTypeGuesser)
|
||||||
|
->getFormFactory();
|
||||||
|
|
||||||
|
$formBuilder = $factory->createNamedBuilder('form', 'Symfony\Component\Form\Extension\Core\Type\FormType');
|
||||||
|
|
||||||
|
$formBuilder->add('property1', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', array(
|
||||||
|
'em' => 'default',
|
||||||
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
|
'query_builder' => $repo->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', 1),
|
||||||
|
));
|
||||||
|
|
||||||
|
$formBuilder->add('property2', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', array(
|
||||||
|
'em' => 'default',
|
||||||
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
|
'query_builder' => function (EntityRepository $repo) {
|
||||||
|
return $repo->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', 1);
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
|
$formBuilder->add('property3', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', array(
|
||||||
|
'em' => 'default',
|
||||||
|
'class' => self::SINGLE_IDENT_CLASS,
|
||||||
|
'query_builder' => function (EntityRepository $repo) {
|
||||||
|
return $repo->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', 1);
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
|
$form = $formBuilder->getForm();
|
||||||
|
|
||||||
|
$form->submit(array(
|
||||||
|
'property1' => 1,
|
||||||
|
'property2' => 1,
|
||||||
|
'property3' => 2,
|
||||||
|
));
|
||||||
|
|
||||||
|
$choiceLoader1 = $form->get('property1')->getConfig()->getOption('choice_loader');
|
||||||
|
$choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader');
|
||||||
|
$choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader');
|
||||||
|
|
||||||
|
$this->assertInstanceOf('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface', $choiceLoader1);
|
||||||
|
$this->assertSame($choiceLoader1, $choiceLoader2);
|
||||||
|
$this->assertSame($choiceLoader1, $choiceLoader3);
|
||||||
|
}
|
||||||
|
|
||||||
protected function createRegistryMock($name, $em)
|
protected function createRegistryMock($name, $em)
|
||||||
{
|
{
|
||||||
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
|
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
|
||||||
|
@ -48,6 +48,19 @@
|
|||||||
<!-- CoreExtension -->
|
<!-- CoreExtension -->
|
||||||
<service id="form.property_accessor" alias="property_accessor" public="false" />
|
<service id="form.property_accessor" alias="property_accessor" public="false" />
|
||||||
|
|
||||||
|
<service id="form.choice_list_factory.default" class="Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory" public="false"/>
|
||||||
|
|
||||||
|
<service id="form.choice_list_factory.property_access" class="Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator" public="false">
|
||||||
|
<argument type="service" id="form.choice_list_factory.default"/>
|
||||||
|
<argument type="service" id="form.property_accessor"/>
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="form.choice_list_factory.cached" class="Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator" public="false">
|
||||||
|
<argument type="service" id="form.choice_list_factory.property_access"/>
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="form.choice_list_factory" alias="form.choice_list_factory.cached" public="false"/>
|
||||||
|
|
||||||
<service id="form.type.form" class="Symfony\Component\Form\Extension\Core\Type\FormType">
|
<service id="form.type.form" class="Symfony\Component\Form\Extension\Core\Type\FormType">
|
||||||
<argument type="service" id="form.property_accessor" />
|
<argument type="service" id="form.property_accessor" />
|
||||||
<tag name="form.type" />
|
<tag name="form.type" />
|
||||||
@ -60,6 +73,7 @@
|
|||||||
</service>
|
</service>
|
||||||
<service id="form.type.choice" class="Symfony\Component\Form\Extension\Core\Type\ChoiceType">
|
<service id="form.type.choice" class="Symfony\Component\Form\Extension\Core\Type\ChoiceType">
|
||||||
<tag name="form.type" />
|
<tag name="form.type" />
|
||||||
|
<argument type="service" id="form.choice_list_factory"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="form.type.collection" class="Symfony\Component\Form\Extension\Core\Type\CollectionType">
|
<service id="form.type.collection" class="Symfony\Component\Form\Extension\Core\Type\CollectionType">
|
||||||
<tag name="form.type" />
|
<tag name="form.type" />
|
||||||
|
@ -286,7 +286,6 @@ class ProfilerController
|
|||||||
'end' => $end,
|
'end' => $end,
|
||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
'panel' => null,
|
'panel' => null,
|
||||||
'request' => $request,
|
|
||||||
)), 200, array('Content-Type' => 'text/html'));
|
)), 200, array('Content-Type' => 'text/html'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +331,6 @@ class ProfilerController
|
|||||||
$tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end);
|
$tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end);
|
||||||
|
|
||||||
return new RedirectResponse($this->generator->generate('_profiler_search_results', array(
|
return new RedirectResponse($this->generator->generate('_profiler_search_results', array(
|
||||||
'request' => $request,
|
|
||||||
'token' => $tokens ? $tokens[0]['token'] : 'empty',
|
'token' => $tokens ? $tokens[0]['token'] : 'empty',
|
||||||
'ip' => $ip,
|
'ip' => $ip,
|
||||||
'method' => $method,
|
'method' => $method,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
|
||||||
use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator;
|
use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator;
|
||||||
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
|
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
|
||||||
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
||||||
@ -44,7 +45,11 @@ class ChoiceType extends AbstractType
|
|||||||
|
|
||||||
public function __construct(ChoiceListFactoryInterface $choiceListFactory = null)
|
public function __construct(ChoiceListFactoryInterface $choiceListFactory = null)
|
||||||
{
|
{
|
||||||
$this->choiceListFactory = $choiceListFactory ?: new PropertyAccessDecorator(new DefaultChoiceListFactory());
|
$this->choiceListFactory = $choiceListFactory ?: new CachingFactoryDecorator(
|
||||||
|
new PropertyAccessDecorator(
|
||||||
|
new DefaultChoiceListFactory()
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +90,7 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->markTestSkipped('Cannot test when open_basedir is set');
|
$this->markTestSkipped('Cannot test when open_basedir is set');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->iniSet('open_basedir', dirname(PHP_BINARY).(!defined('HHVM_VERSION') ? PATH_SEPARATOR.'/' : ''));
|
$this->iniSet('open_basedir', dirname(PHP_BINARY).(!defined('HHVM_VERSION') || HHVM_VERSION_ID >= 30800 ? PATH_SEPARATOR.'/' : ''));
|
||||||
|
|
||||||
$finder = new ExecutableFinder();
|
$finder = new ExecutableFinder();
|
||||||
$result = $finder->find($this->getPhpBinaryName());
|
$result = $finder->find($this->getPhpBinaryName());
|
||||||
@ -108,7 +108,7 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->setPath('');
|
$this->setPath('');
|
||||||
$this->iniSet('open_basedir', PHP_BINARY.(!defined('HHVM_VERSION') ? PATH_SEPARATOR.'/' : ''));
|
$this->iniSet('open_basedir', PHP_BINARY.(!defined('HHVM_VERSION') || HHVM_VERSION_ID >= 30800 ? PATH_SEPARATOR.'/' : ''));
|
||||||
|
|
||||||
$finder = new ExecutableFinder();
|
$finder = new ExecutableFinder();
|
||||||
$result = $finder->find($this->getPhpBinaryName(), false);
|
$result = $finder->find($this->getPhpBinaryName(), false);
|
||||||
|
Reference in New Issue
Block a user