@@ -169,7 +169,7 @@ |
||
169 | 169 | /** |
170 | 170 | * @return null|Rule |
171 | 171 | */ |
172 | - public function getItem(): ?Rule |
|
172 | + public function getItem(): ? Rule |
|
173 | 173 | { |
174 | 174 | return $this->_item; |
175 | 175 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function addNew($routes): bool |
63 | 63 | { |
64 | 64 | foreach ($routes as $route) { |
65 | - $this->manager->add($this->manager->createPermission('/' . trim($route, ' /'))); |
|
65 | + $this->manager->add($this->manager->createPermission('/'.trim($route, ' /'))); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $this->invalidate(); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | public function remove($routes): bool |
81 | 81 | { |
82 | 82 | foreach ($routes as $route) { |
83 | - $item = $this->manager->createPermission('/' . trim($route, '/')); |
|
83 | + $item = $this->manager->createPermission('/'.trim($route, '/')); |
|
84 | 84 | $this->manager->remove($item); |
85 | 85 | } |
86 | 86 | $this->invalidate(); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | protected function getRouteRecursive($module, &$result): void |
163 | 163 | { |
164 | 164 | if (!in_array($module->id, $this->excludeModules)) { |
165 | - $token = "Get Route of '" . get_class($module) . "' with id '" . $module->uniqueId . "'"; |
|
165 | + $token = "Get Route of '".get_class($module)."' with id '".$module->uniqueId."'"; |
|
166 | 166 | Yii::beginProfile($token, __METHOD__); |
167 | 167 | |
168 | 168 | try { |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | $this->getControllerActions($type, $id, $module, $result); |
177 | 177 | } |
178 | 178 | |
179 | - $namespace = trim($module->controllerNamespace, '\\') . '\\'; |
|
179 | + $namespace = trim($module->controllerNamespace, '\\').'\\'; |
|
180 | 180 | $this->getControllerFiles($module, $namespace, '', $result); |
181 | - $all = '/' . ltrim($module->uniqueId . '/*', '/'); |
|
181 | + $all = '/'.ltrim($module->uniqueId.'/*', '/'); |
|
182 | 182 | $result[$all] = $all; |
183 | 183 | } catch (\Exception $exc) { |
184 | 184 | Yii::error($exc->getMessage(), __METHOD__); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function getControllerFiles($module, $namespace, $prefix, &$result) |
202 | 202 | { |
203 | - $path = Yii::getAlias('@' . str_replace('\\', '/', $namespace), false); |
|
203 | + $path = Yii::getAlias('@'.str_replace('\\', '/', $namespace), false); |
|
204 | 204 | $token = "Get controllers from '$path'"; |
205 | 205 | Yii::beginProfile($token, __METHOD__); |
206 | 206 | |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | if ($file == '.' || $file == '..') { |
214 | 214 | continue; |
215 | 215 | } |
216 | - if (is_dir($path . '/' . $file) && preg_match('%^[a-z0-9_/]+$%i', $file . '/')) { |
|
217 | - $this->getControllerFiles($module, $namespace . $file . '\\', $prefix . $file . '/', $result); |
|
216 | + if (is_dir($path.'/'.$file) && preg_match('%^[a-z0-9_/]+$%i', $file.'/')) { |
|
217 | + $this->getControllerFiles($module, $namespace.$file.'\\', $prefix.$file.'/', $result); |
|
218 | 218 | } elseif (strcmp(substr($file, -14), 'Controller.php') === 0) { |
219 | 219 | $baseName = substr(basename($file), 0, -14); |
220 | 220 | $name = strtolower(preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $baseName)); |
221 | 221 | $id = ltrim(str_replace(' ', '-', $name), '-'); |
222 | - $className = $namespace . $baseName . 'Controller'; |
|
222 | + $className = $namespace.$baseName.'Controller'; |
|
223 | 223 | if (strpos($className, '-') === false && class_exists($className) && is_subclass_of($className, 'yii\base\Controller')) { |
224 | - $this->getControllerActions($className, $prefix . $id, $module, $result); |
|
224 | + $this->getControllerActions($className, $prefix.$id, $module, $result); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | protected function getControllerActions($type, $id, $module, &$result) |
244 | 244 | { |
245 | - $token = 'Create controller with cofig=' . VarDumper::dumpAsString($type) . " and id='$id'"; |
|
245 | + $token = 'Create controller with cofig='.VarDumper::dumpAsString($type)." and id='$id'"; |
|
246 | 246 | Yii::beginProfile($token, __METHOD__); |
247 | 247 | |
248 | 248 | try { |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | */ |
267 | 267 | protected function getActionRoutes($controller, &$result) |
268 | 268 | { |
269 | - $token = "Get actions of controller '" . $controller->uniqueId . "'"; |
|
269 | + $token = "Get actions of controller '".$controller->uniqueId."'"; |
|
270 | 270 | Yii::beginProfile($token, __METHOD__); |
271 | 271 | try { |
272 | - $prefix = '/' . $controller->uniqueId . '/'; |
|
272 | + $prefix = '/'.$controller->uniqueId.'/'; |
|
273 | 273 | foreach ($controller->actions() as $id => $value) { |
274 | - $result[$prefix . $id] = $prefix . $id; |
|
274 | + $result[$prefix.$id] = $prefix.$id; |
|
275 | 275 | } |
276 | 276 | $class = new \ReflectionClass($controller); |
277 | 277 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $name = $method->getName(); |
280 | 280 | if ($method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0 && $name !== 'actions') { |
281 | 281 | $name = strtolower(preg_replace('/(?<![A-Z])[A-Z]/', ' \0', substr($name, 6))); |
282 | - $id = $prefix . ltrim(str_replace(' ', '-', $name), '-'); |
|
282 | + $id = $prefix.ltrim(str_replace(' ', '-', $name), '-'); |
|
283 | 283 | $result[$id] = $id; |
284 | 284 | } |
285 | 285 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | if ($this->type == Item::TYPE_ROLE) { |
81 | 81 | $items = $authManager->getRoles(); |
82 | 82 | } else { |
83 | - $items = array_filter($authManager->getPermissions(), function ($item) { |
|
83 | + $items = array_filter($authManager->getPermissions(), function($item) { |
|
84 | 84 | return strpos($item->name, '/') !== 0; |
85 | 85 | }); |
86 | 86 | } |
@@ -86,7 +86,7 @@ discard block |
||
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'], |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | /** |
293 | 293 | * @return null|Item |
294 | 294 | */ |
295 | - public function getItem(): ?Item |
|
295 | + public function getItem(): ? Item |
|
296 | 296 | { |
297 | 297 | return $this->_item; |
298 | 298 | } |