diff --git a/src/Lib/Model/ModelScanner.php b/src/Lib/Model/ModelScanner.php index aef255d1..9ac15d1c 100644 --- a/src/Lib/Model/ModelScanner.php +++ b/src/Lib/Model/ModelScanner.php @@ -46,6 +46,10 @@ public function getModelDecorators(): array { $return = []; + if (!$this->config->isHotReload() && PHP_SAPI !== 'cli') { + return $return; + } + $connection = ConnectionManager::get($this->config->getConnectionName()); $namespaces = $this->config->getNamespaces(); diff --git a/src/Lib/Route/RouteScanner.php b/src/Lib/Route/RouteScanner.php index b200e0f2..9ec3bdb4 100644 --- a/src/Lib/Route/RouteScanner.php +++ b/src/Lib/Route/RouteScanner.php @@ -27,12 +27,18 @@ class RouteScanner */ private array $routes; + /** + * @var bool + */ + private bool $isHotReload; + /** * @param \Cake\Routing\Router $router CakePHP Router * @param \SwaggerBake\Lib\Configuration $config Swagger Configuration */ public function __construct(private Router $router, Configuration $config) { + $this->isHotReload = $config->isHotReload(); $this->prefix = $config->getPrefix(); $this->loadRoutes(); } @@ -58,6 +64,12 @@ private function loadRoutes(): void $routes = []; + if (!$this->isHotReload && PHP_SAPI !== 'cli') { + $this->routes = $routes; + + return; + } + foreach ($this->router::routes() as $route) { if (!$this->isRouteAllowed($route)) { continue;