do not depend on the QueryBuilder from the ORM
This commit is contained in:
parent
4d11bca474
commit
6958d77f0c
@ -14,7 +14,6 @@ namespace Symfony\Bridge\Doctrine\Form\Type;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader;
|
||||
@ -85,13 +84,16 @@ abstract class DoctrineType extends AbstractType implements ResetInterface
|
||||
* For instance in ORM two query builders with an equal SQL string and
|
||||
* equal parameters are considered to be equal.
|
||||
*
|
||||
* @param object $queryBuilder A query builder, type declaration is not present here as there
|
||||
* is no common base class for the different implementations
|
||||
*
|
||||
* @return array|null Array with important QueryBuilder parts or null if
|
||||
* they can't be determined
|
||||
*
|
||||
* @internal This method is public to be usable as callback. It should not
|
||||
* be used in user code.
|
||||
*/
|
||||
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array
|
||||
public function getQueryBuilderPartsForCachingHash($queryBuilder): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ class EntityType extends DoctrineType
|
||||
*/
|
||||
public function getLoader(ObjectManager $manager, $queryBuilder, $class)
|
||||
{
|
||||
if (!$queryBuilder instanceof QueryBuilder) {
|
||||
throw new \TypeError(sprintf('Expected an instance of %s, but got %s.', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder)));
|
||||
}
|
||||
|
||||
return new ORMQueryBuilderLoader($queryBuilder);
|
||||
}
|
||||
|
||||
@ -68,11 +72,17 @@ class EntityType extends DoctrineType
|
||||
* We consider two query builders with an equal SQL string and
|
||||
* equal parameters to be equal.
|
||||
*
|
||||
* @param QueryBuilder $queryBuilder
|
||||
*
|
||||
* @internal This method is public to be usable as callback. It should not
|
||||
* be used in user code.
|
||||
*/
|
||||
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array
|
||||
public function getQueryBuilderPartsForCachingHash($queryBuilder): ?array
|
||||
{
|
||||
if (!$queryBuilder instanceof QueryBuilder) {
|
||||
throw new \TypeError(sprintf('Expected an instance of %s, but got %s.', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder)));
|
||||
}
|
||||
|
||||
return [
|
||||
$queryBuilder->getQuery()->getSQL(),
|
||||
array_map([$this, 'parameterToArray'], $queryBuilder->getParameters()->toArray()),
|
||||
|
Reference in New Issue
Block a user