/**
  * Load model
  * @param Entity $entity
  * @param string|integer $id
  * @return ActiveRecord mixed
  */
 public function loadModel($entity, $id)
 {
     if ($this->_model) {
         return $this->_model;
     }
     /* @var ActiveRecord $modelClass */
     $modelClass = $entity->getModelName();
     /* @var ActiveQuery $query */
     $query = call_user_func([$modelClass, 'find']);
     $query->where([$entity->primaryKey() => $id]);
     $condition = $entity->getModelConditions();
     if (is_callable($condition)) {
         $query = call_user_func($condition, $query);
     } elseif (is_array($condition)) {
         $query = $query->andWhere($condition);
     }
     $this->_model = $query->one();
     return $this->_model;
 }