@@ -171,6 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Get list of application routes |
| 174 | + * @param \yii\web\Application $module |
|
| 174 | 175 | * @return array |
| 175 | 176 | */ |
| 176 | 177 | public function getAppRoutes($module = null) |
@@ -290,7 +291,7 @@ discard block |
||
| 290 | 291 | /** |
| 291 | 292 | * Get route of action |
| 292 | 293 | * @param \yii\base\Controller $controller |
| 293 | - * @param array $result all controller action. |
|
| 294 | + * @param string $result all controller action. |
|
| 294 | 295 | */ |
| 295 | 296 | protected function getActionRoutes($controller, &$result) |
| 296 | 297 | { |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $r = explode('&', $route); |
| 39 | 39 | $item = $manager->createPermission($this->getPermissionName($route)); |
| 40 | 40 | if (count($r) > 1) { |
| 41 | - $action = '/' . trim($r[0], '/'); |
|
| 41 | + $action = '/'.trim($r[0], '/'); |
|
| 42 | 42 | if (($itemAction = $manager->getPermission($action)) === null) { |
| 43 | 43 | $itemAction = $manager->createPermission($action); |
| 44 | 44 | $manager->add($itemAction); |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | public function getPermissionName($route) |
| 102 | 102 | { |
| 103 | 103 | if (self::PREFIX_BASIC == $this->routePrefix) { |
| 104 | - return self::PREFIX_BASIC . trim($route, self::PREFIX_BASIC); |
|
| 104 | + return self::PREFIX_BASIC.trim($route, self::PREFIX_BASIC); |
|
| 105 | 105 | } else { |
| 106 | - return self::PREFIX_ADVANCED . ltrim(trim($route, self::PREFIX_BASIC), self::PREFIX_ADVANCED); |
|
| 106 | + return self::PREFIX_ADVANCED.ltrim(trim($route, self::PREFIX_BASIC), self::PREFIX_ADVANCED); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | // Step through each configured application |
| 128 | 128 | foreach ($advanced as $id => $configPaths) { |
| 129 | 129 | // Force correct id string. |
| 130 | - $id = $this->routePrefix . ltrim(trim($id), $this->routePrefix); |
|
| 130 | + $id = $this->routePrefix.ltrim(trim($id), $this->routePrefix); |
|
| 131 | 131 | // Create empty config array. |
| 132 | 132 | $config = []; |
| 133 | 133 | // Assemble configuration for current app. |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | unset($app); |
| 144 | 144 | // Prepend the app id to all routes. |
| 145 | 145 | foreach ($r as $route) { |
| 146 | - $routes[$id . $route] = $id . $route; |
|
| 146 | + $routes[$id.$route] = $id.$route; |
|
| 147 | 147 | } |
| 148 | 148 | // Switch back to original app. |
| 149 | 149 | Yii::$app = $yiiApp; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | protected function getRouteRecursive($module, &$result) |
| 204 | 204 | { |
| 205 | - $token = "Get Route of '" . get_class($module) . "' with id '" . $module->uniqueId . "'"; |
|
| 205 | + $token = "Get Route of '".get_class($module)."' with id '".$module->uniqueId."'"; |
|
| 206 | 206 | Yii::beginProfile($token, __METHOD__); |
| 207 | 207 | try { |
| 208 | 208 | foreach ($module->getModules() as $id => $child) { |
@@ -215,9 +215,9 @@ discard block |
||
| 215 | 215 | $this->getControllerActions($type, $id, $module, $result); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $namespace = trim($module->controllerNamespace, '\\') . '\\'; |
|
| 218 | + $namespace = trim($module->controllerNamespace, '\\').'\\'; |
|
| 219 | 219 | $this->getControllerFiles($module, $namespace, '', $result); |
| 220 | - $all = '/' . ltrim($module->uniqueId . '/*', '/'); |
|
| 220 | + $all = '/'.ltrim($module->uniqueId.'/*', '/'); |
|
| 221 | 221 | $result[$all] = $all; |
| 222 | 222 | } catch (\Exception $exc) { |
| 223 | 223 | Yii::error($exc->getMessage(), __METHOD__); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | protected function getControllerFiles($module, $namespace, $prefix, &$result) |
| 237 | 237 | { |
| 238 | - $path = Yii::getAlias('@' . str_replace('\\', '/', $namespace), false); |
|
| 238 | + $path = Yii::getAlias('@'.str_replace('\\', '/', $namespace), false); |
|
| 239 | 239 | $token = "Get controllers from '$path'"; |
| 240 | 240 | Yii::beginProfile($token, __METHOD__); |
| 241 | 241 | try { |
@@ -246,15 +246,15 @@ discard block |
||
| 246 | 246 | if ($file == '.' || $file == '..') { |
| 247 | 247 | continue; |
| 248 | 248 | } |
| 249 | - if (is_dir($path . '/' . $file) && preg_match('%^[a-z0-9_/]+$%i', $file . '/')) { |
|
| 250 | - $this->getControllerFiles($module, $namespace . $file . '\\', $prefix . $file . '/', $result); |
|
| 249 | + if (is_dir($path.'/'.$file) && preg_match('%^[a-z0-9_/]+$%i', $file.'/')) { |
|
| 250 | + $this->getControllerFiles($module, $namespace.$file.'\\', $prefix.$file.'/', $result); |
|
| 251 | 251 | } elseif (strcmp(substr($file, -14), 'Controller.php') === 0) { |
| 252 | 252 | $baseName = substr(basename($file), 0, -14); |
| 253 | 253 | $name = strtolower(preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $baseName)); |
| 254 | 254 | $id = ltrim(str_replace(' ', '-', $name), '-'); |
| 255 | - $className = $namespace . $baseName . 'Controller'; |
|
| 255 | + $className = $namespace.$baseName.'Controller'; |
|
| 256 | 256 | if (strpos($className, '-') === false && class_exists($className) && is_subclass_of($className, 'yii\base\Controller')) { |
| 257 | - $this->getControllerActions($className, $prefix . $id, $module, $result); |
|
| 257 | + $this->getControllerActions($className, $prefix.$id, $module, $result); |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | protected function getControllerActions($type, $id, $module, &$result) |
| 275 | 275 | { |
| 276 | - $token = "Create controller with cofig=" . VarDumper::dumpAsString($type) . " and id='$id'"; |
|
| 276 | + $token = "Create controller with cofig=".VarDumper::dumpAsString($type)." and id='$id'"; |
|
| 277 | 277 | Yii::beginProfile($token, __METHOD__); |
| 278 | 278 | try { |
| 279 | 279 | /* @var $controller \yii\base\Controller */ |
@@ -294,19 +294,19 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | protected function getActionRoutes($controller, &$result) |
| 296 | 296 | { |
| 297 | - $token = "Get actions of controller '" . $controller->uniqueId . "'"; |
|
| 297 | + $token = "Get actions of controller '".$controller->uniqueId."'"; |
|
| 298 | 298 | Yii::beginProfile($token, __METHOD__); |
| 299 | 299 | try { |
| 300 | - $prefix = '/' . $controller->uniqueId . '/'; |
|
| 300 | + $prefix = '/'.$controller->uniqueId.'/'; |
|
| 301 | 301 | foreach ($controller->actions() as $id => $value) { |
| 302 | - $result[$prefix . $id] = $prefix . $id; |
|
| 302 | + $result[$prefix.$id] = $prefix.$id; |
|
| 303 | 303 | } |
| 304 | 304 | $class = new \ReflectionClass($controller); |
| 305 | 305 | foreach ($class->getMethods() as $method) { |
| 306 | 306 | $name = $method->getName(); |
| 307 | 307 | if ($method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0 && $name !== 'actions') { |
| 308 | 308 | $name = strtolower(preg_replace('/(?<![A-Z])[A-Z]/', ' \0', substr($name, 6))); |
| 309 | - $id = $prefix . ltrim(str_replace(' ', '-', $name), '-'); |
|
| 309 | + $id = $prefix.ltrim(str_replace(' ', '-', $name), '-'); |
|
| 310 | 310 | $result[$id] = $id; |
| 311 | 311 | } |
| 312 | 312 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | while (($pos = strrpos($r, '/')) > 0) { |
| 123 | 123 | $r = substr($r, 0, $pos); |
| 124 | - if ($user->can($r . '/*', $params)) { |
|
| 124 | + if ($user->can($r.'/*', $params)) { |
|
| 125 | 125 | return true; |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | while (($pos = strrpos($r, '/')) > 0) { |
| 135 | 135 | $r = substr($r, 0, $pos); |
| 136 | - if (isset($routes[$r . '/*'])) { |
|
| 136 | + if (isset($routes[$r.'/*'])) { |
|
| 137 | 137 | return true; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -150,19 +150,19 @@ discard block |
||
| 150 | 150 | protected static function normalizeRoute($route, $advanced = false) |
| 151 | 151 | { |
| 152 | 152 | if ($route === '') { |
| 153 | - $normalized = '/' . Yii::$app->controller->getRoute(); |
|
| 153 | + $normalized = '/'.Yii::$app->controller->getRoute(); |
|
| 154 | 154 | } elseif (strncmp($route, '/', 1) === 0) { |
| 155 | 155 | $normalized = $route; |
| 156 | 156 | } elseif (strpos($route, '/') === false) { |
| 157 | - $normalized = '/' . Yii::$app->controller->getUniqueId() . '/' . $route; |
|
| 157 | + $normalized = '/'.Yii::$app->controller->getUniqueId().'/'.$route; |
|
| 158 | 158 | } elseif (($mid = Yii::$app->controller->module->getUniqueId()) !== '') { |
| 159 | - $normalized = '/' . $mid . '/' . $route; |
|
| 159 | + $normalized = '/'.$mid.'/'.$route; |
|
| 160 | 160 | } else { |
| 161 | - $normalized = '/' . $route; |
|
| 161 | + $normalized = '/'.$route; |
|
| 162 | 162 | } |
| 163 | 163 | // Prefix @app-id to route. |
| 164 | 164 | if ($advanced) { |
| 165 | - $normalized = Route::PREFIX_ADVANCED . Yii::$app->id . $normalized; |
|
| 165 | + $normalized = Route::PREFIX_ADVANCED.Yii::$app->id.$normalized; |
|
| 166 | 166 | } |
| 167 | 167 | return $normalized; |
| 168 | 168 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | return implode(' ', $result); |
| 235 | 235 | } |
| 236 | - return preg_replace_callback('/\\{([\w\-\/]+)\\}/', function ($matches) use ($user) { |
|
| 236 | + return preg_replace_callback('/\\{([\w\-\/]+)\\}/', function($matches) use ($user) { |
|
| 237 | 237 | return static::checkRoute($matches[1], [], $user) ? "{{$matches[1]}}" : ''; |
| 238 | 238 | }, $buttons); |
| 239 | 239 | } |