예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 /**
  * Finds the Permission model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $name
  * @return Permission the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($name)
 {
     $model = new Permission();
     $permission = $model->authManager->getPermission($name);
     if (!($permission === null)) {
         $model->name = $permission->name;
         $model->description = $permission->description;
         $model->setIsNewRecord(false);
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #3
0
파일: Auth.php 프로젝트: apurey/cmf
 /**
  * @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];
 }
예제 #4
0
파일: Role.php 프로젝트: apurey/cmf
 /**
  * @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;
 }