Example #1
0
 /**
  * Loads/creates a model from a persistence layer Record.
  *
  * @param   string  $typeKey    The model type.
  * @param   Record  $record     The persistence layer record.
  * @return  Model
  */
 protected function loadModel($typeKey, Record $record)
 {
     $this->mf->validateResourceTypes($typeKey, $record->getType());
     // Must use the type from the record to cover polymorphic models.
     $metadata = $this->getMetadataForType($record->getType());
     $model = new Model($metadata, $record->getId(), $this, $record);
     $model->getState()->setLoaded();
     $this->dispatchLifecycleEvent(Events::postLoad, $model);
     $this->cache->push($model);
     return $model;
 }