]> _ Git - cubist_cms-back.git/commitdiff
wip #4210 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jun 2022 08:18:26 +0000 (10:18 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jun 2022 08:18:26 +0000 (10:18 +0200)
src/app/Cache.php [deleted file]
src/app/Cache/CacheManager.php [new file with mode: 0644]
src/app/CubistBackpackServiceProvider.php

diff --git a/src/app/Cache.php b/src/app/Cache.php
deleted file mode 100644 (file)
index fc1a485..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Cubist\Backpack;
-
-class Cache extends \Illuminate\Support\Facades\Cache
-{
-    public static function rememberOrRefresh(string $key, \DateTimeInterface|\DateInterval|int $ttl, \Closure $callback, $refresh = false)
-    {
-        if ($refresh) {
-            $data = $callback();
-            self::put($key, $data, $ttl);
-            return $data;
-        } else {
-            return self::remember($key, $ttl, $callback);
-        }
-    }
-}
diff --git a/src/app/Cache/CacheManager.php b/src/app/Cache/CacheManager.php
new file mode 100644 (file)
index 0000000..b645b0e
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+namespace Cubist\Backpack\Cache;
+use Closure;
+
+class CacheManager extends \Illuminate\Cache\CacheManager
+{
+
+    public function rememberOrRefresh($key, $ttl, Closure $callback, $refresh = false)
+    {
+        if ($refresh) {
+            $data = $callback();
+            $this->put($key, $data, $ttl);
+            return $data;
+        }
+        return $this->remember($key, $ttl, $callback);
+    }
+}
index 8a81bd4bcbaa4f8c9f359db34a592144e5a33af8..f7e0d78c2c99115bfd4ac86496e5af96bbf56d99 100644 (file)
@@ -2,12 +2,12 @@
 
 namespace Cubist\Backpack;
 
+use Cubist\Backpack\Cache\CacheManager;
 use Cubist\Backpack\Console\Commands\MigrateCommand;
 use Cubist\Backpack\Console\Commands\GenerateCommand;
 use Cubist\Backpack\Console\Commands\InstallCommand;
 use Cubist\Backpack\Console\Commands\LocaleCopy;
 use Cubist\Backpack\Console\Commands\LocaleSlugReset;
-use Cubist\Backpack\Console\Commands\PrecacheCommand;
 use Cubist\Backpack\Console\Commands\RefreshComposedAttributesCommand;
 use Cubist\Backpack\Console\Commands\SearchIndexCommand;
 use Cubist\Backpack\Console\Commands\UpdateCommand;
@@ -69,6 +69,10 @@ class CubistBackpackServiceProvider extends ServiceProvider
 
         $configs = ['app', 'cubist'];
 
+        $this->app->singleton('cache', function ($app) {
+            return new CacheManager($app);
+        });
+
         foreach ($configs as $config) {
             $this->mergeConfigFrom($resourcesDir . '/config/' . $config . '.php', $config);
         }
@@ -81,8 +85,12 @@ class CubistBackpackServiceProvider extends ServiceProvider
             RefreshComposedAttributesCommand::class,
             SearchIndexCommand::class,
             LocaleCopy::class,
-            LocaleSlugReset::class,
-            PrecacheCommand::class
+            LocaleSlugReset::class
         ]);
     }
+
+    public function provides()
+    {
+        return ['cache'];
+    }
 }