Optimize EntityType by only loading choices for values in the same way that EntityLoader customization does (if you provide a query_builder).

This commit is contained in:
Guilherme Blanco 2015-02-05 17:41:00 +00:00
parent 542f60457d
commit 2185883520
1 changed files with 4 additions and 2 deletions

View File

@ -218,8 +218,10 @@ class EntityChoiceList extends ObjectChoiceList
if (!$this->loaded) {
// Optimize performance in case we have an entity loader and
// a single-field identifier
if ($this->idAsValue && $this->entityLoader) {
$unorderedEntities = $this->entityLoader->getEntitiesByIds($this->idField, $values);
if ($this->idAsValue) {
$unorderedEntities = $this->entityLoader
? $this->entityLoader->getEntitiesByIds($this->idField, $values)
: $this->em->getRepository($this->class)->findBy(array($this->idField => $values));
$entitiesByValue = array();
$entities = array();