/** * {@inheritdoc} */ public function isDirty() { if (true === $this->hasDirtyModels()) { return true; } return parent::isDirty(); }
/** * {@inheritDoc} */ public function rewind() { $this->loadFromStore(); parent::rewind(); }
/** * Loads/fills a collection of empty (unloaded) models with data from the persistence layer. * * @param Collections\AbstractCollection $collection * @return Model[] */ public function loadCollection(Collections\AbstractCollection $collection) { $identifiers = $collection->getIdentifiers(); if (empty($identifiers)) { // Nothing to query. return []; } if ($collection instanceof Collections\InverseCollection) { $recordSet = $this->retrieveInverseRecords($collection->getOwner()->getType(), $collection->getType(), $collection->getIdentifiers(), $collection->getQueryField()); } else { $recordSet = $this->retrieveRecords($collection->getType(), $collection->getIdentifiers()); } $models = []; foreach ($recordSet as $record) { if (true === $this->cache->has($record['type'], $record['identifier'])) { $models[] = $this->cache->get($record['type'], $record['identifier']); continue; } $models[] = $this->loadModel($collection->getType(), $record); } return $models; }