Skip to content

Commit

Permalink
Handle on null.
Browse files Browse the repository at this point in the history
  • Loading branch information
gent-fella-health committed Oct 26, 2020
1 parent 08a3fde commit 5c1eee5
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function boot()
public function map(Router $router)
{
$middleware = config('larapi-components.protection_middleware');
$extraRoutes = config('larapi-components.extra_routes');
$extraRoutes = config('larapi-components.extra_routes') ?? null;

$highLevelParts = array_map(function ($namespace) {
return glob(sprintf('%s%s*', $namespace, DIRECTORY_SEPARATOR), GLOB_ONLYDIR);
Expand Down Expand Up @@ -67,26 +67,28 @@ public function map(Router $router)
});
}

foreach ($extraRoutes as $routeName => $route) {
$path = sprintf('%s/%s.php', $componentRoot, $routeName);
if (is_array($extraRoutes)) {
foreach ($extraRoutes as $routeName => $route) {
$path = sprintf('%s/%s.php', $componentRoot, $routeName);

if (!file_exists($path)) {
continue;
}
if (!file_exists($path)) {
continue;
}

$namespace = sprintf(
'%s\\%s\\'. $route['namespace'],
$part,
$component
);
$namespace = sprintf(
'%s\\%s\\'. $route['namespace'],
$part,
$component
);

$router->group([
$router->group([
'middleware' => $route['middleware'],
'namespace' => $namespace,
'prefix' => $route['prefix']
], function ($router) use ($path) {
require $path;
});
}
}
}
}
Expand Down

0 comments on commit 5c1eee5

Please sign in to comment.