Skip to content

Commit

Permalink
feat: don't load routes if routes are cached
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Jun 15, 2023
1 parent ec69be1 commit 4f0feb4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Loaders/RoutesLoaderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ trait RoutesLoaderTrait
*/
public function runRoutesAutoLoader(): void
{
if (!$this->shouldRegisterRoutes()) {
return;
}

$allContainerPaths = Apiato::getAllContainerPaths();

foreach ($allContainerPaths as $containerPath) {
Expand All @@ -27,6 +31,15 @@ public function runRoutesAutoLoader(): void
}
}

private function shouldRegisterRoutes(): bool
{
if ($this->app->routesAreCached()) {
return false;
}

return true;
}

/**
* Register the Containers API routes files
* @param string $containerPath
Expand Down

0 comments on commit 4f0feb4

Please sign in to comment.