Skip to content

Commit

Permalink
Fix "[Form] Add flexibility for EntityType"
Browse files Browse the repository at this point in the history
This fixes commit e0a1294.
  • Loading branch information
nicolas-grekas committed Aug 2, 2015
1 parent a5a9385 commit eb08baa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
*
* This property should only be accessed through queryBuilder.
*
* @var QueryBuilder|null
* @var QueryBuilder
*/
private $queryBuilder;

Expand Down Expand Up @@ -68,7 +68,7 @@ public function __construct($queryBuilder, $manager = null, $class = null)

$queryBuilder = $queryBuilder($manager->getRepository($class));

if (null !== $queryBuilder && !$queryBuilder instanceof QueryBuilder) {
if (!$queryBuilder instanceof QueryBuilder) {
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder');
}
}
Expand All @@ -81,10 +81,6 @@ public function __construct($queryBuilder, $manager = null, $class = null)
*/
public function getEntities()
{
if (null === $this->queryBuilder) {
return array();
}

return $this->queryBuilder->getQuery()->execute();
}

Expand All @@ -93,10 +89,6 @@ public function getEntities()
*/
public function getEntitiesByIds($identifier, array $values)
{
if (null === $this->queryBuilder) {
return array();
}

$qb = clone ($this->queryBuilder);
$alias = current($qb->getRootAliases());
$parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function configureOptions(OptionsResolver $resolver)
if (is_callable($queryBuilder)) {
$queryBuilder = call_user_func($queryBuilder, $options['em']->getRepository($options['class']));

if (!$queryBuilder instanceof QueryBuilder) {
if (null !== $queryBuilder && !$queryBuilder instanceof QueryBuilder) {
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder()

public function testConfigureQueryBuilderWithClosureReturningNull()
{
$field = $this->factory->createNamed('name', 'entity', null, array(
$field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
'em' => 'default',
'class' => self::SINGLE_IDENT_CLASS,
'query_builder' => function () {
Expand Down

0 comments on commit eb08baa

Please sign in to comment.