]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/render/PageCacheManager.php
Merge pull request #1628 from ArthurHoaro/fix/nginx-config
[github/shaarli/Shaarli.git] / application / render / PageCacheManager.php
index bd91fe0d3d54fbb2fb22d0bf71171e23ab4b9900..97805c3524605bae07b30cb06b4c935517c8126c 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace Shaarli\Render;
 
+use Shaarli\Feed\CachedPage;
+
 /**
  * Cache utilities
  */
@@ -10,9 +12,13 @@ class PageCacheManager
     /** @var string Cache directory */
     protected $pageCacheDir;
 
-    public function __construct(string $pageCacheDir)
+    /** @var bool */
+    protected $isLoggedIn;
+
+    public function __construct(string $pageCacheDir, bool $isLoggedIn)
     {
         $this->pageCacheDir = $pageCacheDir;
+        $this->isLoggedIn = $isLoggedIn;
     }
 
     /**
@@ -42,4 +48,13 @@ class PageCacheManager
         // Purge page cache shared by sessions.
         $this->purgeCachedPages();
     }
+
+    public function getCachePage(string $pageUrl): CachedPage
+    {
+        return new CachedPage(
+            $this->pageCacheDir,
+            $pageUrl,
+            false === $this->isLoggedIn
+        );
+    }
 }