@@ -162,7 +162,7 @@ |
||
162 | 162 | * |
163 | 163 | * @param string $id |
164 | 164 | * |
165 | - * @return null|\self |
|
165 | + * @return AuthItemModel|null |
|
166 | 166 | */ |
167 | 167 | public static function find(string $id) |
168 | 168 | { |
@@ -86,7 +86,7 @@ |
||
86 | 86 | [['name', 'description', 'data', 'ruleName'], 'trim'], |
87 | 87 | [['name', 'type'], 'required'], |
88 | 88 | ['ruleName', 'checkRule'], |
89 | - ['name', 'unique', 'when' => function () { |
|
89 | + ['name', 'unique', 'when' => function() { |
|
90 | 90 | return $this->getIsNewRecord() || ($this->_item->name != $this->name); |
91 | 91 | }], |
92 | 92 | ['type', 'integer'], |
@@ -192,7 +192,7 @@ |
||
192 | 192 | */ |
193 | 193 | public function getViewPath(): string |
194 | 194 | { |
195 | - return $this->module->getViewPath() . DIRECTORY_SEPARATOR . 'item'; |
|
195 | + return $this->module->getViewPath().DIRECTORY_SEPARATOR.'item'; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * Lists of all auth items |
68 | 68 | * |
69 | - * @return mixed |
|
69 | + * @return string |
|
70 | 70 | */ |
71 | 71 | public function actionIndex() |
72 | 72 | { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param string $id |
87 | 87 | * |
88 | - * @return mixed |
|
88 | + * @return string |
|
89 | 89 | */ |
90 | 90 | public function actionView(string $id) |
91 | 91 | { |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param string $id |
146 | 146 | * |
147 | - * @return mixed |
|
147 | + * @return Response |
|
148 | 148 | */ |
149 | 149 | public function actionDelete(string $id) |
150 | 150 | { |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | // string, required, root directory of all source files |
5 | - 'sourcePath' => __DIR__ . DIRECTORY_SEPARATOR . '..', |
|
5 | + 'sourcePath' => __DIR__.DIRECTORY_SEPARATOR.'..', |
|
6 | 6 | // array, required, list of language codes that the extracted messages |
7 | 7 | // should be translated to. For example, ['zh-CN', 'de']. |
8 | 8 | 'languages' => ['en'], |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | return true; |
54 | 54 | } catch (\Exception $e) { |
55 | 55 | echo "Rolling transaction back\n"; |
56 | - echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n"; |
|
57 | - echo $e->getTraceAsString() . "\n"; |
|
56 | + echo 'Exception: '.$e->getMessage().' ('.$e->getFile().':'.$e->getLine().")\n"; |
|
57 | + echo $e->getTraceAsString()."\n"; |
|
58 | 58 | $transaction->rollBack(); |
59 | 59 | |
60 | 60 | return false; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | return true; |
80 | 80 | } catch (\Exception $e) { |
81 | 81 | echo "Rolling transaction back\n"; |
82 | - echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n"; |
|
83 | - echo $e->getTraceAsString() . "\n"; |
|
82 | + echo 'Exception: '.$e->getMessage().' ('.$e->getFile().':'.$e->getLine().")\n"; |
|
83 | + echo $e->getTraceAsString()."\n"; |
|
84 | 84 | $transaction->rollBack(); |
85 | 85 | |
86 | 86 | return false; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $permission->ruleName = $ruleName; |
127 | 127 | $permission->data = $data; |
128 | 128 | $this->authManager->add($permission); |
129 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
129 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
130 | 130 | |
131 | 131 | return $permission; |
132 | 132 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $role->ruleName = $ruleName; |
151 | 151 | $role->data = $data; |
152 | 152 | $this->authManager->add($role); |
153 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
153 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
154 | 154 | |
155 | 155 | return $role; |
156 | 156 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | /** @var Rule $rule */ |
179 | 179 | $rule = \Yii::createObject($definition); |
180 | 180 | $this->authManager->add($rule); |
181 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
181 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
182 | 182 | |
183 | 183 | return $rule; |
184 | 184 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | echo " > adding $child->name as child to $parent->name ..."; |
256 | 256 | $time = microtime(true); |
257 | 257 | $this->authManager->addChild($parent, $child); |
258 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
258 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | echo " > removing $child->name from $parent->name ..."; |
276 | 276 | $time = microtime(true); |
277 | 277 | $this->authManager->removeChild($parent, $child); |
278 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
278 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | echo " > assigning $role->name to user $userId ..."; |
293 | 293 | $time = microtime(true); |
294 | 294 | $this->authManager->assign($role, $userId); |
295 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
295 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $role->ruleName = $ruleName; |
317 | 317 | $role->data = $data; |
318 | 318 | $this->authManager->update($role->name, $role); |
319 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
319 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
320 | 320 | |
321 | 321 | return $role; |
322 | 322 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | echo " > removing role $role->name ..."; |
336 | 336 | $time = microtime(true); |
337 | 337 | $this->authManager->remove($role); |
338 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
338 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $permission->ruleName = $ruleName; |
360 | 360 | $permission->data = $data; |
361 | 361 | $this->authManager->update($permission->name, $permission); |
362 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
362 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
363 | 363 | |
364 | 364 | return $permission; |
365 | 365 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | echo " > removing permission $permission->name ..."; |
379 | 379 | $time = microtime(true); |
380 | 380 | $this->authManager->remove($permission); |
381 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
381 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | 'name' => $ruleName, |
400 | 400 | ]); |
401 | 401 | $this->authManager->update($ruleName, $rule); |
402 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
402 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
403 | 403 | |
404 | 404 | return $rule; |
405 | 405 | } |
@@ -418,6 +418,6 @@ discard block |
||
418 | 418 | echo " > removing rule $rule->name ..."; |
419 | 419 | $time = microtime(true); |
420 | 420 | $this->authManager->remove($rule); |
421 | - echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
421 | + echo ' done (time: '.sprintf('%.3f', microtime(true) - $time)."s)\n"; |
|
422 | 422 | } |
423 | 423 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected function getVendorPath() |
72 | 72 | { |
73 | - return dirname(__DIR__) . '/vendor'; |
|
73 | + return dirname(__DIR__).'/vendor'; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | 'data' => 'string', |
107 | 107 | 'created_at' => 'integer', |
108 | 108 | 'updated_at' => 'integer', |
109 | - 'FOREIGN KEY (rule_name) REFERENCES ' . '{{%auth_rule}}' . ' (name) ON DELETE SET NULL ON UPDATE CASCADE', |
|
109 | + 'FOREIGN KEY (rule_name) REFERENCES '.'{{%auth_rule}}'.' (name) ON DELETE SET NULL ON UPDATE CASCADE', |
|
110 | 110 | ])->execute(); |
111 | 111 | |
112 | 112 | $db->createCommand()->createTable('{{%auth_item_child}}', [ |
113 | 113 | 'parent' => 'string', |
114 | 114 | 'child' => 'string', |
115 | 115 | 'PRIMARY KEY (parent, child)', |
116 | - 'FOREIGN KEY (parent) REFERENCES ' . '{{%auth_item}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
117 | - 'FOREIGN KEY (child) REFERENCES ' . '{{%auth_item}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
116 | + 'FOREIGN KEY (parent) REFERENCES '.'{{%auth_item}}'.' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
117 | + 'FOREIGN KEY (child) REFERENCES '.'{{%auth_item}}'.' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
118 | 118 | ])->execute(); |
119 | 119 | |
120 | 120 | $db->createCommand()->createTable('{{%auth_assignment}}', [ |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'user_id' => 'integer', |
123 | 123 | 'created_at' => 'integer', |
124 | 124 | 'PRIMARY KEY (item_name, user_id)', |
125 | - 'FOREIGN KEY (item_name) REFERENCES ' . '{{%auth_item}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
125 | + 'FOREIGN KEY (item_name) REFERENCES '.'{{%auth_item}}'.' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
126 | 126 | ])->execute(); |
127 | 127 | |
128 | 128 | $db->createCommand()->createTable('{{%user}}', [ |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | $controller = $action->controller; |
34 | 34 | $params = ArrayHelper::getValue($this->params, $action->id, []); |
35 | 35 | |
36 | - if (Yii::$app->user->can('/' . $action->getUniqueId(), $params)) { |
|
36 | + if (Yii::$app->user->can('/'.$action->getUniqueId(), $params)) { |
|
37 | 37 | return true; |
38 | 38 | } |
39 | 39 | |
40 | 40 | do { |
41 | - if (Yii::$app->user->can('/' . ltrim($controller->getUniqueId() . '/*', '/'))) { |
|
41 | + if (Yii::$app->user->can('/'.ltrim($controller->getUniqueId().'/*', '/'))) { |
|
42 | 42 | return true; |
43 | 43 | } |
44 | 44 | $controller = $controller->module; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | if ($this->owner instanceof Module) { |
106 | 106 | $ownerId = $this->owner->getUniqueId(); |
107 | 107 | $id = $action->getUniqueId(); |
108 | - if (!empty($ownerId) && strpos($id, $ownerId . '/') === 0) { |
|
108 | + if (!empty($ownerId) && strpos($id, $ownerId.'/') === 0) { |
|
109 | 109 | $id = substr($id, strlen($ownerId) + 1); |
110 | 110 | } |
111 | 111 | } else { |
@@ -7,7 +7,7 @@ |
||
7 | 7 | |
8 | 8 | $context = $this->context; |
9 | 9 | $labels = $this->context->getLabels(); |
10 | -$this->title = Yii::t('yii2mod.rbac', 'Update ' . $labels['Item'] . ' : {0}', $model->name); |
|
10 | +$this->title = Yii::t('yii2mod.rbac', 'Update '.$labels['Item'].' : {0}', $model->name); |
|
11 | 11 | $this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', $labels['Items']), 'url' => ['index']]; |
12 | 12 | $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]]; |
13 | 13 | $this->params['breadcrumbs'][] = Yii::t('yii2mod.rbac', 'Update'); |
@@ -6,7 +6,7 @@ |
||
6 | 6 | /* @var $model \yii2mod\rbac\models\AuthItemModel */ |
7 | 7 | |
8 | 8 | $labels = $this->context->getLabels(); |
9 | -$this->title = Yii::t('yii2mod.rbac', 'Create ' . $labels['Item']); |
|
9 | +$this->title = Yii::t('yii2mod.rbac', 'Create '.$labels['Item']); |
|
10 | 10 | $this->params['breadcrumbs'][] = ['label' => Yii::t('yii2mod.rbac', $labels['Items']), 'url' => ['index']]; |
11 | 11 | $this->params['breadcrumbs'][] = $this->title; |
12 | 12 | $this->render('/layouts/_sidebar'); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | <div class="item-index"> |
18 | 18 | <h1><?php echo Html::encode($this->title); ?></h1> |
19 | 19 | <p> |
20 | - <?php echo Html::a(Yii::t('yii2mod.rbac', 'Create ' . $labels['Item']), ['create'], ['class' => 'btn btn-success']); ?> |
|
20 | + <?php echo Html::a(Yii::t('yii2mod.rbac', 'Create '.$labels['Item']), ['create'], ['class' => 'btn btn-success']); ?> |
|
21 | 21 | </p> |
22 | 22 | <?php Pjax::begin(['timeout' => 5000, 'enablePushState' => false]); ?> |
23 | 23 |