]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/front/ShaarliMiddleware.php
Move all admin controller into a dedicated group
[github/shaarli/Shaarli.git] / application / front / ShaarliMiddleware.php
index 707489d065b0951b125738464e5ba8af553fb465..a2a3837b9e2bd1560899af8e249f5dc9338d4c52 100644 (file)
@@ -40,7 +40,7 @@ class ShaarliMiddleware
      */
     public function __invoke(Request $request, Response $response, callable $next): Response
     {
-        $this->container->basePath = rtrim($request->getUri()->getBasePath(), '/');
+        $this->initBasePath($request);
 
         try {
             if (!is_file($this->container->conf->getConfigFileExt())
@@ -125,4 +125,14 @@ class ShaarliMiddleware
 
         return true;
     }
+
+    /**
+     * Initialize the URL base path if it hasn't been defined yet.
+     */
+    protected function initBasePath(Request $request): void
+    {
+        if (null === $this->container->basePath) {
+            $this->container->basePath = rtrim($request->getUri()->getBasePath(), '/');
+        }
+    }
 }