/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Permission::find()->where(['type' => Permission::TYPE]); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * @return array */ public static function getRbacItems() { /** * @var $role Role * @var $permission Permission */ $roles = []; $permissions = []; foreach (Role::find()->where(['type' => Role::TYPE])->all() as $role) { $roles = ArrayHelper::merge($roles, [$role->name => $role->name]); } foreach (Permission::find()->where(['type' => Permission::TYPE])->all() as $permission) { $permissions = ArrayHelper::merge($permissions, [$permission->name => $permission->name]); } return ['roles' => $roles, 'permissions' => $permissions]; }
/** * @return array */ public function getPermissions() { /* @var $model Permission */ $permissions = []; $models = Permission::find()->where(['type' => Permission::TYPE])->all(); foreach ($models as $model) { $permissions = ArrayHelper::merge($permissions, [$model->name => $model->name]); } return $permissions; }