33namespace yii2mod \cms \controllers ;
44
55use Yii ;
6- use yii2mod \ cms \ models \ CmsModel ;
6+ use yii \ filters \ VerbFilter ;
77use yii \web \Controller ;
88use yii \web \NotFoundHttpException ;
9- use yii \ filters \ VerbFilter ;
9+ use yii2mod \ cms \ models \ CmsModel ;
1010use yii2mod \editable \EditableAction ;
1111use yii2mod \toggle \actions \ToggleAction ;
1212
1313/**
1414 * Class CmsController
15+ *
1516 * @package yii2mod\cms\controllers
1617 */
1718class CmsController extends Controller
@@ -48,14 +49,14 @@ public function behaviors()
4849 {
4950 return [
5051 'verbs ' => [
51- 'class ' => VerbFilter::className () ,
52+ 'class ' => VerbFilter::class ,
5253 'actions ' => [
5354 'index ' => ['get ' ],
5455 'create ' => ['get ' , 'post ' ],
5556 'update ' => ['get ' , 'post ' ],
56- 'delete ' => ['post ' ]
57+ 'delete ' => ['post ' ],
5758 ],
58- ]
59+ ],
5960 ];
6061 }
6162
@@ -66,14 +67,14 @@ public function actions()
6667 {
6768 return [
6869 'edit-page ' => [
69- 'class ' => EditableAction::className () ,
70- 'modelClass ' => CmsModel::className () ,
71- 'forceCreate ' => false
70+ 'class ' => EditableAction::class ,
71+ 'modelClass ' => CmsModel::class ,
72+ 'forceCreate ' => false ,
7273 ],
7374 'toggle ' => [
74- 'class ' => ToggleAction::className () ,
75- 'modelClass ' => CmsModel::className () ,
76- ]
75+ 'class ' => ToggleAction::class ,
76+ 'modelClass ' => CmsModel::class ,
77+ ],
7778 ];
7879 }
7980
@@ -89,7 +90,7 @@ public function actionIndex()
8990
9091 return $ this ->render ($ this ->indexView , [
9192 'dataProvider ' => $ dataProvider ,
92- 'searchModel ' => $ searchModel
93+ 'searchModel ' => $ searchModel,
9394 ]);
9495 }
9596
@@ -106,11 +107,12 @@ public function actionCreate()
106107
107108 if ($ model ->load (Yii::$ app ->request ->post ()) && $ model ->save ()) {
108109 Yii::$ app ->session ->setFlash ('success ' , Yii::t ('yii2mod.cms ' , 'Page has been created. ' ));
110+
109111 return $ this ->redirect (['index ' ]);
110112 }
111113
112114 return $ this ->render ($ this ->createView , [
113- 'model ' => $ model
115+ 'model ' => $ model,
114116 ]);
115117 }
116118
@@ -119,7 +121,7 @@ public function actionCreate()
119121 *
120122 * If update is successful, the browser will be redirected to the 'index' page.
121123 *
122- * @param integer $id
124+ * @param int $id
123125 *
124126 * @return mixed
125127 */
@@ -129,11 +131,12 @@ public function actionUpdate($id)
129131
130132 if ($ model ->load (Yii::$ app ->request ->post ()) && $ model ->save ()) {
131133 Yii::$ app ->session ->setFlash ('success ' , Yii::t ('yii2mod.cms ' , 'Page has been updated. ' ));
134+
132135 return $ this ->redirect (['index ' ]);
133136 }
134137
135138 return $ this ->render ($ this ->updateView , [
136- 'model ' => $ model
139+ 'model ' => $ model,
137140 ]);
138141 }
139142
@@ -142,22 +145,23 @@ public function actionUpdate($id)
142145 *
143146 * If deletion is successful, the browser will be redirected to the 'index' page.
144147 *
145- * @param integer $id
148+ * @param int $id
146149 *
147150 * @return mixed
148151 */
149152 public function actionDelete ($ id )
150153 {
151154 $ this ->findModel ($ id )->delete ();
152155 Yii::$ app ->session ->setFlash ('success ' , Yii::t ('yii2mod.cms ' , 'Page has been deleted. ' ));
156+
153157 return $ this ->redirect (['index ' ]);
154158 }
155159
156160 /**
157161 * Finds the CmsModel model based on its primary key value.
158162 * If the model is not found, a 404 HTTP exception will be thrown.
159163 *
160- * @param integer $id
164+ * @param int $id
161165 *
162166 * @return CmsModel the loaded model
163167 *
@@ -173,4 +177,4 @@ protected function findModel($id)
173177 throw new NotFoundHttpException (Yii::t ('yii2mod.cms ' , 'The requested page does not exist. ' ));
174178 }
175179 }
176- }
180+ }
0 commit comments