@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | // +---------------------------------------------------------------------- |
| 9 | 9 | // | Author: liu21st <[email protected]> |
| 10 | 10 | // +---------------------------------------------------------------------- |
| 11 | -declare (strict_types = 1); |
|
| 11 | +declare(strict_types=1); |
|
| 12 | 12 | |
| 13 | 13 | namespace think; |
| 14 | 14 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | public function __construct(App $app) |
| 58 | 58 | { |
| 59 | 59 | $this->app = $app; |
| 60 | - $this->multi = is_dir($this->app->getBasePath() . 'controller') ? false : true; |
|
| 60 | + $this->multi = is_dir($this->app->getBasePath().'controller') ? false : true; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | protected function dispatchToRoute($request) |
| 195 | 195 | { |
| 196 | - $withRoute = $this->app->config->get('app.with_route', true) ? function () { |
|
| 196 | + $withRoute = $this->app->config->get('app.with_route', true) ? function() { |
|
| 197 | 197 | $this->loadRoutes(); |
| 198 | 198 | } : null; |
| 199 | 199 | |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | protected function loadMiddleware(): void |
| 207 | 207 | { |
| 208 | - if (is_file($this->app->getBasePath() . 'middleware.php')) { |
|
| 209 | - $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php'); |
|
| 208 | + if (is_file($this->app->getBasePath().'middleware.php')) { |
|
| 209 | + $this->app->middleware->import(include $this->app->getBasePath().'middleware.php'); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $routePath = $this->getRoutePath(); |
| 222 | 222 | |
| 223 | 223 | if (is_dir($routePath)) { |
| 224 | - $files = glob($routePath . '*.php'); |
|
| 224 | + $files = glob($routePath.'*.php'); |
|
| 225 | 225 | foreach ($files as $file) { |
| 226 | 226 | include $file; |
| 227 | 227 | } |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | protected function getRoutePath(): string |
| 239 | 239 | { |
| 240 | - if ($this->isMulti() && is_dir($this->app->getAppPath() . 'route')) { |
|
| 241 | - return $this->app->getAppPath() . 'route' . DIRECTORY_SEPARATOR; |
|
| 240 | + if ($this->isMulti() && is_dir($this->app->getAppPath().'route')) { |
|
| 241 | + return $this->app->getAppPath().'route'.DIRECTORY_SEPARATOR; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - return $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($this->isMulti() ? $this->getName() . DIRECTORY_SEPARATOR : ''); |
|
| 244 | + return $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($this->isMulti() ? $this->getName().DIRECTORY_SEPARATOR : ''); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | $appName = $map[$name]; |
| 329 | 329 | } |
| 330 | 330 | } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { |
| 331 | - throw new HttpException(404, 'app not exists:' . $name); |
|
| 331 | + throw new HttpException(404, 'app not exists:'.$name); |
|
| 332 | 332 | } elseif ($name && isset($map['*'])) { |
| 333 | 333 | $appName = $map['*']; |
| 334 | 334 | } else { |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | if ($name) { |
| 339 | - $this->app->request->setRoot('/' . $name); |
|
| 339 | + $this->app->request->setRoot('/'.$name); |
|
| 340 | 340 | $this->app->request->setPathinfo(strpos($path, '/') ? ltrim(strstr($path, '/'), '/') : ''); |
| 341 | 341 | } |
| 342 | 342 | } |
@@ -355,11 +355,11 @@ discard block |
||
| 355 | 355 | { |
| 356 | 356 | $this->name = $appName; |
| 357 | 357 | $this->app->request->setApp($appName); |
| 358 | - $this->app->setAppPath($this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR); |
|
| 359 | - $this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); |
|
| 358 | + $this->app->setAppPath($this->path ?: $this->app->getBasePath().$appName.DIRECTORY_SEPARATOR); |
|
| 359 | + $this->app->setRuntimePath($this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$appName.DIRECTORY_SEPARATOR); |
|
| 360 | 360 | |
| 361 | 361 | // 设置应用命名空间 |
| 362 | - $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); |
|
| 362 | + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\'.$appName); |
|
| 363 | 363 | |
| 364 | 364 | //加载应用 |
| 365 | 365 | $this->loadApp($appName); |
@@ -376,34 +376,34 @@ discard block |
||
| 376 | 376 | if (is_dir($this->app->getAppPath())) { |
| 377 | 377 | $appPath = $this->app->getAppPath(); |
| 378 | 378 | |
| 379 | - if (is_file($appPath . 'common.php')) { |
|
| 380 | - include_once $appPath . 'common.php'; |
|
| 379 | + if (is_file($appPath.'common.php')) { |
|
| 380 | + include_once $appPath.'common.php'; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | $configPath = $this->app->getConfigPath(); |
| 384 | 384 | |
| 385 | 385 | $files = []; |
| 386 | 386 | |
| 387 | - if (is_dir($appPath . 'config')) { |
|
| 388 | - $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 389 | - } elseif (is_dir($configPath . $appName)) { |
|
| 390 | - $files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 387 | + if (is_dir($appPath.'config')) { |
|
| 388 | + $files = array_merge($files, glob($appPath.'config'.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 389 | + } elseif (is_dir($configPath.$appName)) { |
|
| 390 | + $files = array_merge($files, glob($configPath.$appName.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | foreach ($files as $file) { |
| 394 | 394 | $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if (is_file($appPath . 'event.php')) { |
|
| 398 | - $this->app->loadEvent(include $appPath . 'event.php'); |
|
| 397 | + if (is_file($appPath.'event.php')) { |
|
| 398 | + $this->app->loadEvent(include $appPath.'event.php'); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if (is_file($appPath . 'middleware.php')) { |
|
| 402 | - $this->app->middleware->import(include $appPath . 'middleware.php'); |
|
| 401 | + if (is_file($appPath.'middleware.php')) { |
|
| 402 | + $this->app->middleware->import(include $appPath.'middleware.php'); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if (is_file($appPath . 'provider.php')) { |
|
| 406 | - $this->app->bind(include $appPath . 'provider.php'); |
|
| 405 | + if (is_file($appPath.'provider.php')) { |
|
| 406 | + $this->app->bind(include $appPath.'provider.php'); |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |