Skip to content

[Autocomplete] Does not work when Repository does not extend EntityRepository #3075

@janopae

Description

@janopae

When your Entities repository does not extend \Doctrine\ORM\EntityRepository, every request to the EntityAutocompleteController will result in a type error.

This is because the repository is accessed through a wrapper around the Doctrine registry (\Symfony\UX\Autocomplete\Doctrine\DoctrineRegistryWrapper), which instead of ObjectRepository typehints \Doctrine\ORM\EntityRepository.

The only case when methods of EntityRepository that are not in ObjectRepository are used, are however in

$queryBuilder = $queryBuilder ?: $repository->createQueryBuilder('entity');
, only when a FormType does not declare a 'query_builder' – only then, $repository->createQueryBuilder('entity'); is being used. It should be possible to use Entity Repositories that don't extend the Doctrine implementation as long as you provide a 'query_builder'.

The normal EntityType allows using repositories that don't descent from Doctrine's default implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AutocompleteRFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions