From 0b11cfc178e3f97650d415e45798937f64279248 Mon Sep 17 00:00:00 2001 From: Vladimir Jimenez Date: Sun, 26 Feb 2023 12:20:03 -0800 Subject: [PATCH] Server Linked Assets at the right time in serve --- src/allejo/stakx/Console/Command/BuildCommand.php | 1 + src/allejo/stakx/Server/WebServer.php | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/allejo/stakx/Console/Command/BuildCommand.php b/src/allejo/stakx/Console/Command/BuildCommand.php index 85d064e9..f00e2aff 100644 --- a/src/allejo/stakx/Console/Command/BuildCommand.php +++ b/src/allejo/stakx/Console/Command/BuildCommand.php @@ -59,6 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $this->configureConfigurationFile($input); + /** @var Website $website */ $website = $this->getContainer()->get(Website::class); $website->build(); diff --git a/src/allejo/stakx/Server/WebServer.php b/src/allejo/stakx/Server/WebServer.php index 291d26c0..5ca13daa 100644 --- a/src/allejo/stakx/Server/WebServer.php +++ b/src/allejo/stakx/Server/WebServer.php @@ -75,6 +75,12 @@ public static function create(RouteMapper $routeMapper, Compiler $compiler, Asse $context = new RequestContext($urlPath); $matcher = new UrlMatcher($routes, $context); + // If we have a Linked Asset, let's serve it + if (($file = $assetManager->getExplicitAsset(self::normalizePath($urlPath))) !== null) + { + return self::makeResponse($file); + } + try { $parameters = $matcher->match($urlPath); @@ -88,12 +94,6 @@ public static function create(RouteMapper $routeMapper, Compiler $compiler, Asse } catch (ResourceNotFoundException $e) { - // If we have a "manual" asset, let's serve from it - if (($file = $assetManager->getExplicitAsset(self::normalizePath($urlPath))) !== null) - { - return self::makeResponse($file); - } - // Our AssetManager only populates its registry of assets when files are copied at build time. Because // the web server doesn't perform the full site compilation, our manager is not populated. For this // reason, we manually look through the filesystem and load from there.