Fixed MongoODM entity loader. Improved loading behavior of entities and documents by reusing entity loader.

This commit is contained in:
Guilherme Blanco 2015-03-20 17:40:16 +00:00
parent d5a8a1009b
commit 529d99c567
2 changed files with 7 additions and 7 deletions

View File

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

View File

@ -66,9 +66,11 @@ abstract class DoctrineType extends AbstractType
$type = $this;
$loader = function (Options $options) use ($type) {
if (null !== $options['query_builder']) {
return $type->getLoader($options['em'], $options['query_builder'], $options['class']);
}
$queryBuilder = (null !== $options['query_builder'])
? $options['query_builder']
: $options['em']->getRepository($options['class'])->createQueryBuilder('e');
return $type->getLoader($options['em'], $queryBuilder, $options['class']);
};
$choiceList = function (Options $options) use (&$choiceListCache, $propertyAccessor) {