toir427 /
yii2-admin
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace toir427\admin\controllers; |
||||
| 4 | |||||
| 5 | use Yii; |
||||
| 6 | use toir427\admin\models\Route; |
||||
| 7 | use yii\web\Controller; |
||||
| 8 | use yii\filters\VerbFilter; |
||||
| 9 | |||||
| 10 | /** |
||||
| 11 | * Description of RuleController |
||||
| 12 | * |
||||
| 13 | * @author Misbahul D Munir <[email protected]> |
||||
| 14 | * @since 1.0 |
||||
| 15 | */ |
||||
| 16 | class RouteController extends Controller |
||||
| 17 | { |
||||
| 18 | public function behaviors() |
||||
| 19 | { |
||||
| 20 | return [ |
||||
| 21 | 'verbs' => [ |
||||
| 22 | 'class' => VerbFilter::className(), |
||||
| 23 | 'actions' => [ |
||||
| 24 | 'create' => ['post'], |
||||
| 25 | 'assign' => ['post'], |
||||
| 26 | 'remove' => ['post'], |
||||
| 27 | 'refresh' => ['post'], |
||||
| 28 | ], |
||||
| 29 | ], |
||||
| 30 | ]; |
||||
| 31 | } |
||||
| 32 | /** |
||||
| 33 | * Lists all Route models. |
||||
| 34 | * @return mixed |
||||
| 35 | */ |
||||
| 36 | public function actionIndex() |
||||
| 37 | { |
||||
| 38 | $model = new Route(); |
||||
| 39 | return $this->render('index', ['routes' => $model->getRoutes()]); |
||||
| 40 | } |
||||
| 41 | |||||
| 42 | /** |
||||
| 43 | * Creates a new AuthItem model. |
||||
| 44 | * If creation is successful, the browser will be redirected to the 'view' page. |
||||
| 45 | * @return mixed |
||||
| 46 | */ |
||||
| 47 | public function actionCreate() |
||||
| 48 | { |
||||
| 49 | Yii::$app->getResponse()->format = 'json'; |
||||
| 50 | $routes = Yii::$app->getRequest()->post('route', ''); |
||||
| 51 | $routes = preg_split('/\s*,\s*/', trim($routes), -1, PREG_SPLIT_NO_EMPTY); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 52 | $model = new Route(); |
||||
| 53 | $model->addNew($routes); |
||||
|
0 ignored issues
–
show
It seems like
$routes can also be of type false; however, parameter $routes of toir427\admin\models\Route::addNew() does only seem to accept array, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 54 | return $model->getRoutes(); |
||||
| 55 | } |
||||
| 56 | |||||
| 57 | /** |
||||
| 58 | * Assign routes |
||||
| 59 | * @return array |
||||
| 60 | */ |
||||
| 61 | public function actionAssign() |
||||
| 62 | { |
||||
| 63 | $routes = Yii::$app->getRequest()->post('routes', []); |
||||
| 64 | $model = new Route(); |
||||
| 65 | $model->addNew($routes); |
||||
| 66 | Yii::$app->getResponse()->format = 'json'; |
||||
| 67 | return $model->getRoutes(); |
||||
| 68 | } |
||||
| 69 | |||||
| 70 | /** |
||||
| 71 | * Remove routes |
||||
| 72 | * @return array |
||||
| 73 | */ |
||||
| 74 | public function actionRemove() |
||||
| 75 | { |
||||
| 76 | $routes = Yii::$app->getRequest()->post('routes', []); |
||||
| 77 | $model = new Route(); |
||||
| 78 | $model->remove($routes); |
||||
| 79 | Yii::$app->getResponse()->format = 'json'; |
||||
| 80 | return $model->getRoutes(); |
||||
| 81 | } |
||||
| 82 | |||||
| 83 | /** |
||||
| 84 | * Refresh cache |
||||
| 85 | * @return type |
||||
|
0 ignored issues
–
show
The type
toir427\admin\controllers\type was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 86 | */ |
||||
| 87 | public function actionRefresh() |
||||
| 88 | { |
||||
| 89 | $model = new Route(); |
||||
| 90 | $model->invalidate(); |
||||
| 91 | Yii::$app->getResponse()->format = 'json'; |
||||
| 92 | return $model->getRoutes(); |
||||
|
0 ignored issues
–
show
|
|||||
| 93 | } |
||||
| 94 | } |
||||
| 95 |