Skip to content

Commit 51a8b11

Browse files
committed
bug #13606 [Form][DoctrineBridge] Optimize EntityType by only loading choices for values restricted by values (guilhermeblanco)
This PR was merged into the 2.7 branch. Discussion ---------- [Form][DoctrineBridge] Optimize EntityType by only loading choices for values restricted by values | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Optimize EntityType by only loading choices for values in the same way that EntityLoader customization does (if you provide a query_builder). Commits ------- 2185883 Optimize EntityType by only loading choices for values in the same way that EntityLoader customization does (if you provide a query_builder).
2 parents 542f604 + 2185883 commit 51a8b11

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,10 @@ public function getChoicesForValues(array $values)
218218
if (!$this->loaded) {
219219
// Optimize performance in case we have an entity loader and
220220
// a single-field identifier
221-
if ($this->idAsValue && $this->entityLoader) {
222-
$unorderedEntities = $this->entityLoader->getEntitiesByIds($this->idField, $values);
221+
if ($this->idAsValue) {
222+
$unorderedEntities = $this->entityLoader
223+
? $this->entityLoader->getEntitiesByIds($this->idField, $values)
224+
: $this->em->getRepository($this->class)->findBy(array($this->idField => $values));
223225
$entitiesByValue = array();
224226
$entities = array();
225227

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy