コード例 #1
0
 public function safeDown()
 {
     AuthItemChild::deleteAll(['parent' => $this->getRoles()]);
     AuthItemChild::deleteAll(['child' => $this->getRoles()]);
     AuthItem::deleteAll(['name' => $this->getRoles()]);
     return true;
 }
コード例 #2
0
 public function down()
 {
     foreach ($this->getPermissions() as $role => $permissions) {
         AuthItemChild::deleteAll(['parent' => $role, 'child' => $permissions]);
         AuthItem::deleteAll(['name' => $permissions]);
     }
     return true;
 }
コード例 #3
0
 public function search($params)
 {
     $query = AuthItemChild::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'parent', $this->parent])->andFilterWhere(['like', 'child', $this->child]);
     return $dataProvider;
 }
コード例 #4
0
 /**
  * Callback for $this->menuWidget() method.
  * @param array $data data to process.
  * @return array processed data.
  */
 public function menuCallback($data)
 {
     $contextMenu = ARTreeMenuWidget::this()->commonOptions()['contextmenu'];
     $contextMenu['items'] = ['create' => $contextMenu['items']['create'], 'delete' => $contextMenu['items']['delete']];
     $data['options'] = ['types' => $this->types, 'contextmenu' => $contextMenu];
     $items = AuthItem::find()->where(['type' => \yii\rbac\Item::TYPE_ROLE])->indexBy('name')->all();
     $relations = AuthItemChild::find()->all();
     $data['items'] = $this->generateTree($items, $relations);
     return $data;
 }
コード例 #5
0
 /**
  * @param bool $id
  * @throws NotFoundHttpException
  * @return AuthItemChild
  */
 protected function findModel($id = false)
 {
     if (!$id) {
         $model = new AuthItemChild();
     } else {
         if (!($model = AuthItemChild::findOne($id))) {
             throw new NotFoundHttpException('Model not found.');
         }
     }
     return $model;
 }
コード例 #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthItemChildren()
 {
     return $this->hasMany(AuthItemChild::className(), ['parent' => 'name']);
 }