Ejemplo n.º 1
0
 /**
  * Loads/fills a collection of empty (unloaded) models with data from the persistence layer.
  *
  * @param   AbstractCollection  $collection
  * @return  Model[]
  */
 public function loadCollection(AbstractCollection $collection)
 {
     $identifiers = $collection->getIdentifiers();
     if (empty($identifiers)) {
         // Nothing to query.
         return $collection;
     }
     if ($collection instanceof InverseCollection) {
         $records = $this->retrieveInverseRecords($collection->getOwner()->getType(), $collection->getType(), $collection->getIdentifiers(), $collection->getQueryField());
     } else {
         $records = $this->retrieveRecords($collection->getType(), $collection->getIdentifiers());
     }
     $models = [];
     foreach ($records as $record) {
         if (true === $this->cache->has($record->getType(), $record->getId())) {
             $models[] = $this->cache->get($record->getType(), $record->getId());
             continue;
         }
         $models[] = $this->loadModel($collection->getType(), $record);
     }
     return $models;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritDoc}
  *
  * Overwritten to ensure the collection is loaded, since references aren't sent to inverse collections.
  */
 public function allWithoutLoad()
 {
     $this->loadFromStore();
     return parent::allWithoutLoad();
 }