Skip to content

Commit 4055c0d

Browse files
committed
Fixed Router merge route array bug
1 parent d2580a9 commit 4055c0d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Framework/Router/TastRouter.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function register(Container $app)
2222
if (file_exists($routeCacheFile) && (!$app['debug'])) {
2323
$routeConfigAll = require $routeCacheFile;
2424
} else {
25-
$routeConfigAll = $this->parseAllRoutes($app,$routeConfigAll);
25+
$routeConfigAll = $this->parseAllRoutes($app, $routeConfigAll);
2626

2727
if (!$app['debug']) {
2828
$fs = new Filesystem();
@@ -42,7 +42,7 @@ public function register(Container $app)
4242
RouterService::setParameters($app);
4343
}
4444

45-
private function parseAllRoutes($app,$routeConfigAll = [])
45+
private function parseAllRoutes($app, $routeConfigAll = [])
4646
{
4747
$routeConfigAll = $this->parseRoutesConfig(__BASEDIR__ . '/config/routes.yml', $routeConfigAll);
4848

@@ -62,7 +62,10 @@ private function parseRoutesConfig($routesFile, $routeConfigAll)
6262
if (is_file(__BASEDIR__ . "/src/" . $resource) && file_exists(__BASEDIR__ . "/src/" . $resource)) {
6363
$array = YamlService::parse(file_get_contents(__BASEDIR__ . "/src/" . $resource));
6464
}
65-
$routeConfigAll = array_merge($routeConfigAll, $array);
65+
66+
if (!empty($array)) {
67+
$routeConfigAll = array_merge($routeConfigAll, $array);
68+
}
6669
}
6770

6871
return $routeConfigAll;

0 commit comments

Comments
 (0)