Skip to content

Commit

Permalink
Merge 791a2db into 088a25b
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Mar 14, 2020
2 parents 088a25b + 791a2db commit b0eae43
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Route/RoutePageGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function update(SiteInterface $site, OutputInterface $output = null, $cle
// Iterate over declared routes from the routing mechanism
foreach ($this->router->getRouteCollection()->all() as $name => $route) {
$name = trim($name);
$displayName = $this->displayName($name);

$knowRoutes[] = $name;

Expand Down Expand Up @@ -136,7 +137,7 @@ public function update(SiteInterface $site, OutputInterface $output = null, $cle

$page = $this->pageManager->create([
'routeName' => $name,
'name' => $name,
'name' => $displayName,
'url' => $route->getPath(),
'site' => $site,
'requestMethod' => $requirements['_method'] ??
Expand Down Expand Up @@ -166,6 +167,7 @@ public function update(SiteInterface $site, OutputInterface $output = null, $cle
// Iterate over error pages
foreach ($this->exceptionListener->getHttpErrorCodes() as $name) {
$name = trim((string) $name);
$displayName = $this->displayName($name);

$knowRoutes[] = $name;

Expand All @@ -177,7 +179,7 @@ public function update(SiteInterface $site, OutputInterface $output = null, $cle
if (!$page) {
$params = [
'routeName' => $name,
'name' => $name,
'name' => $displayName,
'decorate' => false,
'site' => $site,
];
Expand Down Expand Up @@ -253,10 +255,11 @@ private function createRootPage(SiteInterface $site): PageInterface
if ('/' === $route->getPath()) {
$requirements = $route->getRequirements();
$name = trim($name);
$displayName = $this->displayName($name);

return $this->pageManager->create([
'routeName' => $name,
'name' => $name,
'name' => $displayName,
'url' => $route->getPath(),
'site' => $site,
'requestMethod' => $requirements['_method'] ?? 'GET|POST|HEAD|DELETE|PUT',
Expand All @@ -274,4 +277,9 @@ private function createRootPage(SiteInterface $site): PageInterface
'slug' => '/',
]);
}

private function displayName(string $name): string
{
return ucwords(trim(str_replace('_', ' ', $name)));
}
}

0 comments on commit b0eae43

Please sign in to comment.