Skip to content

Commit 3f8a159

Browse files
author
Igor Chepurnoy
committed
code style fixes, add verbFilterConfig property to ManageController
1 parent 68b3431 commit 3f8a159

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

Widget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function init()
2121

2222
$request = Yii::$app->getRequest();
2323

24-
if ($request->enableCsrfValidation) {
24+
if ($request->enableCsrfValidation && isset($this->options['imageUpload'])) {
2525
$this->options['uploadImageFields'][$request->csrfParam] = $request->getCsrfToken();
2626
$this->options['uploadFileFields'][$request->csrfParam] = $request->getCsrfToken();
2727
}

controllers/ManageController.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace yii2mod\cms\controllers;
44

55
use Yii;
6-
use yii\filters\VerbFilter;
76
use yii\web\Controller;
87
use yii\web\NotFoundHttpException;
98
use yii\web\UploadedFile;
@@ -43,12 +42,25 @@ class ManageController extends Controller
4342
public $modelClass = 'yii2mod\cms\models\CmsModel';
4443

4544
/**
46-
* @var string model class name for attachment model
45+
* @var string class name for attachment model
4746
*/
4847
public $attachmentModelClass = 'yii2mod\cms\models\AttachmentModel';
49-
48+
49+
/**
50+
* @var array verb filter config
51+
*/
52+
public $verbFilterConfig = [
53+
'class' => 'yii\filters\VerbFilter',
54+
'actions' => [
55+
'index' => ['get'],
56+
'create' => ['get', 'post'],
57+
'update' => ['get', 'post'],
58+
'delete' => ['post'],
59+
'file-upload' => ['post'],
60+
],
61+
];
62+
5063
/**
51-
*
5264
* @var array access control config
5365
*/
5466
public $accessControlConfig = [
@@ -61,23 +73,13 @@ class ManageController extends Controller
6173
],
6274
];
6375

64-
6576
/**
6677
* @inheritdoc
6778
*/
6879
public function behaviors()
6980
{
7081
return [
71-
'verbs' => [
72-
'class' => VerbFilter::class,
73-
'actions' => [
74-
'index' => ['get'],
75-
'create' => ['get', 'post'],
76-
'update' => ['get', 'post'],
77-
'delete' => ['post'],
78-
'file-upload' => ['post'],
79-
],
80-
],
82+
'verbs' => $this->verbFilterConfig,
8183
'access' => $this->accessControlConfig,
8284
];
8385
}
@@ -96,7 +98,7 @@ public function actions()
9698
}
9799

98100
/**
99-
* Lists all CmsModel models.
101+
* List of all cms models.
100102
*
101103
* @return mixed
102104
*/
@@ -112,7 +114,7 @@ public function actionIndex()
112114
}
113115

114116
/**
115-
* Creates a new CmsModel model.
117+
* Creates a new CmsModel.
116118
*
117119
* If creation is successful, the browser will be redirected to the 'index' page.
118120
*
@@ -134,7 +136,7 @@ public function actionCreate()
134136
}
135137

136138
/**
137-
* Updates an existing CmsModel model.
139+
* Updates an existing CmsModel.
138140
*
139141
* If update is successful, the browser will be redirected to the 'index' page.
140142
*
@@ -158,7 +160,7 @@ public function actionUpdate($id)
158160
}
159161

160162
/**
161-
* Deletes an existing CmsModel model.
163+
* Deletes an existing CmsModel.
162164
*
163165
* If deletion is successful, the browser will be redirected to the 'index' page.
164166
*
@@ -197,7 +199,7 @@ public function actionFileUpload()
197199
}
198200

199201
/**
200-
* Finds the CmsModel model based on its primary key value.
202+
* Finds the CmsModel based on its primary key value.
201203
* If the model is not found, a 404 HTTP exception will be thrown.
202204
*
203205
* @param int $id

models/AttachmentModel.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public function attributeLabels()
4747
];
4848
}
4949

50+
/**
51+
* @inheritdoc
52+
*/
5053
public function behaviors()
5154
{
5255
return [

0 commit comments

Comments
 (0)