Skip to content

Instantly share code, notes, and snippets.

@gms8994
Created February 18, 2016 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gms8994/9fc801bea80f5dc146ea to your computer and use it in GitHub Desktop.
Save gms8994/9fc801bea80f5dc146ea to your computer and use it in GitHub Desktop.
public function instantiate($class) {
$model = Yii::$app->modelMapper->instantiateObject(strtolower($class));
if (is_null($model)) {
$entityConfigId = substr($this->type, strlen("entity_"));
$entityConfig = \epmx\frontend\common\models\EntityConfig::findOne(['id' => $entityConfigId]);
$model = new \epmx\frontend\common\models\Entity(['entityConfig' => $entityConfig]);
}
return $model;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment