| @@ 36-45 (lines=10) @@ | ||
| 33 | /** |
|
| 34 | * @throws ServerErrorHttpException |
|
| 35 | */ |
|
| 36 | public function init() |
|
| 37 | { |
|
| 38 | parent::init(); |
|
| 39 | if (false === is_subclass_of($this->modelName, '\yii\db\ActiveRecord')) { |
|
| 40 | throw new ServerErrorHttpException('Model class does not exists'); |
|
| 41 | } |
|
| 42 | if (false === in_array($this->attribute, (new $this->modelName)->attributes())) { |
|
| 43 | throw new ServerErrorHttpException("Model '{$this->modelName}' has no '{$this->attribute}' field'" ); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * @return int |
|
| @@ 19-34 (lines=16) @@ | ||
| 16 | /** |
|
| 17 | * @throws yii\web\ServerErrorHttpException |
|
| 18 | */ |
|
| 19 | public function init() |
|
| 20 | { |
|
| 21 | parent::init(); |
|
| 22 | if (null === $this->modelName) { |
|
| 23 | throw new yii\web\ServerErrorHttpException('Model name should be set in controller actions'); |
|
| 24 | } |
|
| 25 | ||
| 26 | if (!is_subclass_of($this->modelName, '\yii\db\ActiveRecord')) { |
|
| 27 | throw new yii\web\ServerErrorHttpException('Model class does not exists'); |
|
| 28 | } |
|
| 29 | ||
| 30 | $this->objectId = BaseObject::getForClass($this->modelName); |
|
| 31 | if (null === $this->objectId) { |
|
| 32 | throw new yii\web\ServerErrorHttpException('Object does not exists for model.'); |
|
| 33 | } |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @param null $property_id |
|