itstructure /
yii2-rbac-module
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Itstructure\RbacModule\components; |
||
| 4 | |||
| 5 | use yii\base\{Model, InvalidConfigException}; |
||
| 6 | use Itstructure\RbacModule\{ |
||
| 7 | interfaces\ModelInterface, |
||
| 8 | interfaces\ValidateComponentInterface |
||
| 9 | }; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Class RbacValidateComponent |
||
| 13 | * Component class for RBAC. |
||
| 14 | * |
||
| 15 | * @package Itstructure\RbacModule\components |
||
| 16 | */ |
||
| 17 | class RbacValidateComponent extends BaseValidateComponent implements ValidateComponentInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Sets Rbac model. |
||
| 21 | * |
||
| 22 | * @param Model $model |
||
| 23 | * |
||
| 24 | * @throws InvalidConfigException |
||
| 25 | * |
||
| 26 | * @return ModelInterface |
||
| 27 | */ |
||
| 28 | public function setModel(Model $model): ModelInterface |
||
| 29 | { |
||
| 30 | if (!($model instanceof ModelInterface)) { |
||
| 31 | |||
| 32 | $modelClass = (new\ReflectionClass($model)); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 33 | |||
| 34 | throw new InvalidConfigException($modelClass->getNamespaceName() . |
||
| 35 | '\\' . $modelClass->getShortName().' class must be implemented from |
||
| 36 | Itstructure\RbacModule\interfaces\ModelInterface.'); |
||
| 37 | } |
||
| 38 | |||
| 39 | $model->setAuthManager($this->authManager); |
||
| 40 | |||
| 41 | return $model; |
||
| 42 | } |
||
| 43 | } |
||
| 44 |