]> 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 92c0e911b76a5fdf4bef2438a44670fc3f2b96a1..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())
@@ -93,6 +93,7 @@ class ShaarliMiddleware
             return;
         }
 
+        $this->container->updater->setBasePath($this->container->basePath);
         $newUpdates = $this->container->updater->update();
         if (!empty($newUpdates)) {
             $this->container->updater->writeUpdates(
@@ -124,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(), '/');
+        }
+    }
 }