Exemplo n.º 1
0
 public function checkRule($attribute, $params)
 {
     if (!class_exists($this->name)) {
         $this->addError('name', Yii::t('users', 'CLASS_DO_NOT_EXISTS', ['phpClass' => $this->name]));
     } else {
         $newRule = new $this->name();
         $existsRule = AuthRule::findOne(['name' => $newRule->name]);
         if ($existsRule) {
             $this->addError('name', Yii::t('users', 'RBAC_RULE_ALREADY_EXISTS', ['ruleName' => $newRule->name]));
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AuthRule::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'data', $this->data]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRuleName()
 {
     return $this->hasOne(AuthRule::className(), ['name' => 'rule_name']);
 }