@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | protected static function actionToBreadcrumbClass($action) |
18 | 18 | { |
19 | 19 | $arr = explode('/', Inflector::camel2id($action->controller->getUniqueId())); |
20 | - $arr[\count($arr) - 1] = Inflector::camelize(ucfirst($arr[\count($arr) - 1])); |
|
21 | - return static::$crumbsNamespace . '\\' . implode('\\', $arr) . 'Crumbs'; |
|
20 | + $arr[ \count($arr) - 1 ] = Inflector::camelize(ucfirst($arr[ \count($arr) - 1 ])); |
|
21 | + return static::$crumbsNamespace.'\\'.implode('\\', $arr).'Crumbs'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | protected static function actionToBreadcrumbMethod($action) |
25 | 25 | { |
26 | - return 'crumb' . Inflector::camelize($action->id); |
|
26 | + return 'crumb'.Inflector::camelize($action->id); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | |
39 | 39 | if (class_exists($class) && method_exists($class, $method)) { |
40 | 40 | $reflectionMethod = new \ReflectionMethod($class, $method); |
41 | - $data = []; |
|
41 | + $data = [ ]; |
|
42 | 42 | foreach ($reflectionMethod->getParameters() as $p) { |
43 | - $data[] = $params[$p->getName()] ?? null; |
|
43 | + $data[ ] = $params[ $p->getName() ] ?? null; |
|
44 | 44 | } |
45 | - return array_filter(\call_user_func_array([$class, $method], $data)); |
|
45 | + return array_filter(\call_user_func_array([ $class, $method ], $data)); |
|
46 | 46 | } |
47 | 47 | |
48 | - return []; |
|
48 | + return [ ]; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | \ No newline at end of file |
@@ -16,11 +16,11 @@ |
||
16 | 16 | { |
17 | 17 | public function run(array $ids) |
18 | 18 | { |
19 | - $errors = []; |
|
19 | + $errors = [ ]; |
|
20 | 20 | foreach ($ids as $id) { |
21 | - $this->controller->runAction('delete', ['id' => $id]); |
|
21 | + $this->controller->runAction('delete', [ 'id' => $id ]); |
|
22 | 22 | if (Yii::$app->session->hasFlash('error')) { |
23 | - $errors[] = Yii::$app->session->getFlash('error', null, true); |
|
23 | + $errors[ ] = Yii::$app->session->getFlash('error', null, true); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | if (!empty($errors)) { |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | public $breadcrumbsNamespace = 'app\breadcrumbs'; |
46 | 46 | public $breadcrumbsParam = 'breadcrumbs'; |
47 | 47 | |
48 | - protected $params = []; |
|
48 | + protected $params = [ ]; |
|
49 | 49 | |
50 | - public $primaryKey = ['id']; |
|
50 | + public $primaryKey = [ 'id' ]; |
|
51 | 51 | |
52 | 52 | const EVENT_BEFORE_CREATE = 'beforeCreate'; |
53 | 53 | const EVENT_AFTER_CREATE = 'afterCreate'; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $class = $class ?? $this->modelClass; |
82 | 82 | $query = $this->getModelQuery($class); |
83 | 83 | foreach ($this->primaryKey as $key) { |
84 | - $query->andWhere([$key => $id[$key] ?? null]); |
|
84 | + $query->andWhere([ $key => $id[ $key ] ?? null ]); |
|
85 | 85 | } |
86 | 86 | $query = $this->findModelCondition($query); |
87 | 87 | if (($model = $query->one()) !== null) { |
@@ -109,17 +109,17 @@ discard block |
||
109 | 109 | ] |
110 | 110 | ], |
111 | 111 | ]; |
112 | - return new ActiveDataProvider(array_merge(['query' => $query], $options)); |
|
112 | + return new ActiveDataProvider(array_merge([ 'query' => $query ], $options)); |
|
113 | 113 | } |
114 | 114 | |
115 | - public function render($view, $params = []) |
|
115 | + public function render($view, $params = [ ]) |
|
116 | 116 | { |
117 | 117 | if (\Yii::$app->request->isAjax) { |
118 | 118 | return parent::renderAjax($view, $params); |
119 | 119 | } |
120 | 120 | if ($this->breadcrumbsAppdend) { |
121 | 121 | Breadcrumbs::$crumbsNamespace = $this->breadcrumbsNamespace; |
122 | - \Yii::$app->view->params[$this->breadcrumbsParam] = Breadcrumbs::formCrumbs($this->action, $params); |
|
122 | + \Yii::$app->view->params[ $this->breadcrumbsParam ] = Breadcrumbs::formCrumbs($this->action, $params); |
|
123 | 123 | } |
124 | 124 | return parent::render($view, $params); |
125 | 125 | } |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | 'verbs' => [ |
134 | 134 | 'class' => VerbFilter::class, |
135 | 135 | 'actions' => [ |
136 | - 'delete' => ['POST'], |
|
137 | - 'delete-batch' => ['POST'] |
|
136 | + 'delete' => [ 'POST' ], |
|
137 | + 'delete-batch' => [ 'POST' ] |
|
138 | 138 | ], |
139 | 139 | ], |
140 | 140 | ]); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function createRedirect($model) |
199 | 199 | { |
200 | - return ['index']; |
|
200 | + return [ 'index' ]; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function updateRedirect($model) |
208 | 208 | { |
209 | - return ['index']; |
|
209 | + return [ 'index' ]; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function deleteRedirect($model) |
217 | 217 | { |
218 | - return ['index']; |
|
218 | + return [ 'index' ]; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function deleteBatchRedirect() |
226 | 226 | { |
227 | - return ['index']; |
|
227 | + return [ 'index' ]; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | 'class' => UpdateAction::class, |
238 | 238 | 'view' => $this->updateView, |
239 | 239 | 'primaryKeyParam' => $this->primaryKey, |
240 | - 'redirect' => function ($model) { |
|
240 | + 'redirect' => function($model) { |
|
241 | 241 | return $this->updateRedirect($model); |
242 | 242 | } |
243 | 243 | ], |
@@ -246,19 +246,19 @@ discard block |
||
246 | 246 | 'view' => $this->indexView, |
247 | 247 | 'modelClass' => $this->modelClass, |
248 | 248 | 'modelSearchClass' => $this->modelSearchClass, |
249 | - 'query' => function ($class, $action) { |
|
249 | + 'query' => function($class, $action) { |
|
250 | 250 | return $this->getModelQuery($action->modelClass); |
251 | 251 | }, |
252 | - 'dataProvider' => function ($query, IndexAction $action) { |
|
252 | + 'dataProvider' => function($query, IndexAction $action) { |
|
253 | 253 | $searchModel = $action->getSearchModel(); |
254 | 254 | $dataProvider = $this->queryToDataProvider($query); |
255 | 255 | $this->applySearch($query, $dataProvider, $searchModel); |
256 | 256 | return $dataProvider; |
257 | 257 | }, |
258 | - 'condition' => function ($query, IndexAction $action) { |
|
258 | + 'condition' => function($query, IndexAction $action) { |
|
259 | 259 | $this->indexCondition($query); |
260 | 260 | }, |
261 | - 'renderParams' => function ($params) { |
|
261 | + 'renderParams' => function($params) { |
|
262 | 262 | return $this->indexParams($params); |
263 | 263 | } |
264 | 264 | ], |
@@ -45,6 +45,6 @@ |
||
45 | 45 | |
46 | 46 | $dataProvider = is_callable($this->dataProvider) ? call_user_func($this->dataProvider, $query, $this) : $this->dataProvider; |
47 | 47 | |
48 | - return $this->render($this->view, ['searchModel' => $this->searchModel, 'dataProvider' => $dataProvider]); |
|
48 | + return $this->render($this->view, [ 'searchModel' => $this->searchModel, 'dataProvider' => $dataProvider ]); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | $class = $this->modelClass ?: ($this->controller->createClass ?: $this->controller->modelClass); |
35 | 35 | $model = new $class(); |
36 | - $this->controller->trigger(CrudController::EVENT_BEFORE_CREATE, new Event(['model' => $model])); |
|
36 | + $this->controller->trigger(CrudController::EVENT_BEFORE_CREATE, new Event([ 'model' => $model ])); |
|
37 | 37 | if ($this->loadDefaultValues) { |
38 | 38 | $model->loadDefaultValues($this->skipIfSet); |
39 | 39 | } |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | if ($model->load(Yii::$app->request->post())) { |
44 | 44 | if ($model->save()) { |
45 | 45 | Yii::$app->session->setFlash('success', $this->getMessageOnCreate($model)); |
46 | - $this->controller->trigger(CrudController::EVENT_AFTER_CREATE, new Event(['model' => $model])); |
|
46 | + $this->controller->trigger(CrudController::EVENT_AFTER_CREATE, new Event([ 'model' => $model ])); |
|
47 | 47 | return $this->controller->redirect($this->controller->createRedirect($model)); |
48 | 48 | } else { |
49 | - $this->controller->trigger(CrudController::EVENT_ERROR_CREATE, new Event(['model' => $model])); |
|
49 | + $this->controller->trigger(CrudController::EVENT_ERROR_CREATE, new Event([ 'model' => $model ])); |
|
50 | 50 | } |
51 | 51 | Yii::$app->session->setFlash('error', Html::errorSummary($model)); |
52 | 52 | } |
53 | - return $this->controller->render($this->view, ['model' => $model]); |
|
53 | + return $this->controller->render($this->view, [ 'model' => $model ]); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -25,6 +25,6 @@ |
||
25 | 25 | if ($this->updateIfPost && Yii::$app->request->isPost) { |
26 | 26 | return $this->controller->runAction($this->updateAction, $this->params); |
27 | 27 | } |
28 | - return $this->controller->render($this->view, ['model' => $model]); |
|
28 | + return $this->controller->render($this->view, [ 'model' => $model ]); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | public function run() |
24 | 24 | { |
25 | 25 | $model = $this->findModel($this->modelClass ?: $this->controller->updateClass); |
26 | - $this->controller->trigger(CrudController::EVENT_BEFORE_UPDATE_LOAD, new Event(['model' => $model])); |
|
26 | + $this->controller->trigger(CrudController::EVENT_BEFORE_UPDATE_LOAD, new Event([ 'model' => $model ])); |
|
27 | 27 | if ($model->load(Yii::$app->request->post())) { |
28 | - $this->controller->trigger(CrudController::EVENT_AFTER_UPDATE_LOAD, new Event(['model' => $model])); |
|
28 | + $this->controller->trigger(CrudController::EVENT_AFTER_UPDATE_LOAD, new Event([ 'model' => $model ])); |
|
29 | 29 | if ($model->save()) { |
30 | - $this->controller->trigger(CrudController::EVENT_AFTER_UPDATE, new Event(['model' => $model])); |
|
30 | + $this->controller->trigger(CrudController::EVENT_AFTER_UPDATE, new Event([ 'model' => $model ])); |
|
31 | 31 | Yii::$app->session->setFlash('success', $this->getMessageOnUpdate($model)); |
32 | 32 | if ($this->redirect instanceof \Closure) { |
33 | 33 | $url = call_user_func($this->redirect, $model); |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | } |
40 | 40 | return $this->controller->redirect($url); |
41 | 41 | } else { |
42 | - $this->controller->trigger(CrudController::EVENT_ERROR_UPDATE, new Event(['model' => $model])); |
|
42 | + $this->controller->trigger(CrudController::EVENT_ERROR_UPDATE, new Event([ 'model' => $model ])); |
|
43 | 43 | } |
44 | 44 | Yii::$app->session->setFlash('error', Html::errorSummary($model)); |
45 | 45 | } |
46 | - return $this->render($this->view, ['model' => $model]); |
|
46 | + return $this->render($this->view, [ 'model' => $model ]); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public $view; |
15 | 15 | public $modelClass; |
16 | 16 | public $renderParams; |
17 | - protected $params = []; |
|
17 | + protected $params = [ ]; |
|
18 | 18 | |
19 | 19 | public function init() |
20 | 20 | { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | return parent::__call($name, $params); |
37 | 37 | } |
38 | 38 | |
39 | - public function render($view, $params = []) |
|
39 | + public function render($view, $params = [ ]) |
|
40 | 40 | { |
41 | 41 | if ($this->renderParams instanceof \Closure) { |
42 | 42 | $params = array_merge($params, call_user_func($this->renderParams, $params, $this)); |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | |
56 | 56 | public function getPrimaryKeys() |
57 | 57 | { |
58 | - $ids = []; |
|
58 | + $ids = [ ]; |
|
59 | 59 | foreach ((array)$this->primaryKeyParam as $param => $field) { |
60 | 60 | if (is_integer($param)) { |
61 | - $ids[$field] = ArrayHelper::getValue($this->params, $field); |
|
61 | + $ids[ $field ] = ArrayHelper::getValue($this->params, $field); |
|
62 | 62 | } else { |
63 | - $ids[$field] = ArrayHelper::getValue($this->params, $param); |
|
63 | + $ids[ $field ] = ArrayHelper::getValue($this->params, $param); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | return $ids; |