toir427 /
yii2-admin
| 1 | <?php |
||
| 2 | |||
| 3 | namespace toir427\admin\controllers; |
||
| 4 | |||
| 5 | use Yii; |
||
| 6 | use toir427\admin\models\BizRule; |
||
| 7 | use yii\web\Controller; |
||
| 8 | use toir427\admin\models\searchs\BizRule as BizRuleSearch; |
||
| 9 | use yii\filters\VerbFilter; |
||
| 10 | use yii\web\NotFoundHttpException; |
||
| 11 | use toir427\admin\components\Helper; |
||
| 12 | use toir427\admin\components\Configs; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Description of RuleController |
||
| 16 | * |
||
| 17 | * @author Misbahul D Munir <[email protected]> |
||
| 18 | * @since 1.0 |
||
| 19 | */ |
||
| 20 | class RuleController extends Controller |
||
| 21 | { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @inheritdoc |
||
| 25 | */ |
||
| 26 | public function behaviors() |
||
| 27 | { |
||
| 28 | return [ |
||
| 29 | 'verbs' => [ |
||
| 30 | 'class' => VerbFilter::className(), |
||
| 31 | 'actions' => [ |
||
| 32 | 'delete' => ['post'], |
||
| 33 | ], |
||
| 34 | ], |
||
| 35 | ]; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Lists all AuthItem models. |
||
| 40 | * @return mixed |
||
| 41 | */ |
||
| 42 | public function actionIndex() |
||
| 43 | { |
||
| 44 | $searchModel = new BizRuleSearch(); |
||
| 45 | $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); |
||
| 46 | |||
| 47 | return $this->render('index', [ |
||
| 48 | 'dataProvider' => $dataProvider, |
||
| 49 | 'searchModel' => $searchModel, |
||
| 50 | ]); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Displays a single AuthItem model. |
||
| 55 | * @param string $id |
||
| 56 | * @return mixed |
||
| 57 | */ |
||
| 58 | public function actionView($id) |
||
| 59 | { |
||
| 60 | $model = $this->findModel($id); |
||
| 61 | |||
| 62 | return $this->render('view', ['model' => $model]); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Creates a new AuthItem model. |
||
| 67 | * If creation is successful, the browser will be redirected to the 'view' page. |
||
| 68 | * @return mixed |
||
| 69 | */ |
||
| 70 | public function actionCreate() |
||
| 71 | { |
||
| 72 | $model = new BizRule(null); |
||
| 73 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
||
| 74 | Helper::invalidate(); |
||
| 75 | |||
| 76 | return $this->redirect(['view', 'id' => $model->name]); |
||
| 77 | } else { |
||
| 78 | return $this->render('create', ['model' => $model,]); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Updates an existing AuthItem model. |
||
| 84 | * If update is successful, the browser will be redirected to the 'view' page. |
||
| 85 | * @param string $id |
||
| 86 | * @return mixed |
||
| 87 | */ |
||
| 88 | public function actionUpdate($id) |
||
| 89 | { |
||
| 90 | $model = $this->findModel($id); |
||
| 91 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
||
| 92 | Helper::invalidate(); |
||
| 93 | |||
| 94 | return $this->redirect(['view', 'id' => $model->name]); |
||
| 95 | } |
||
| 96 | |||
| 97 | return $this->render('update', ['model' => $model,]); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Deletes an existing AuthItem model. |
||
| 102 | * If deletion is successful, the browser will be redirected to the 'index' page. |
||
| 103 | * @param string $id |
||
| 104 | * @return mixed |
||
| 105 | */ |
||
| 106 | public function actionDelete($id) |
||
| 107 | { |
||
| 108 | $model = $this->findModel($id); |
||
| 109 | Configs::authManager()->remove($model->item); |
||
| 110 | Helper::invalidate(); |
||
| 111 | |||
| 112 | return $this->redirect(['index']); |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Finds the AuthItem model based on its primary key value. |
||
| 117 | * If the model is not found, a 404 HTTP exception will be thrown. |
||
| 118 | * @param string $id |
||
| 119 | * @return AuthItem the loaded model |
||
|
0 ignored issues
–
show
|
|||
| 120 | * @throws HttpException if the model cannot be found |
||
| 121 | */ |
||
| 122 | protected function findModel($id) |
||
| 123 | { |
||
| 124 | $item = Configs::authManager()->getRule($id); |
||
| 125 | if ($item) { |
||
| 126 | return new BizRule($item); |
||
|
0 ignored issues
–
show
|
|||
| 127 | } else { |
||
| 128 | throw new NotFoundHttpException('The requested page does not exist.'); |
||
| 129 | } |
||
| 130 | } |
||
| 131 | } |
||
| 132 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths