]> _ Git - cubist_cms-back.git/commitdiff
wip #4210
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jun 2022 10:59:34 +0000 (12:59 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jun 2022 10:59:34 +0000 (12:59 +0200)
src/app/Console/Commands/PrecacheCommand.php
src/app/Jobs/ModelsPrecache.php

index 967539efcdc1ad1dd592f3a4c9732018efde852b..c1d3e2a9660c7cccf5f30b6a14dde010dddf60b1 100644 (file)
@@ -11,12 +11,16 @@ class PrecacheCommand extends CubistMagicCommand
      *
      * @var string
      */
-    protected $signature = 'cubist:magic:precache';
+    protected $signature = 'cubist:magic:precache {--force}';
 
     public function handle()
     {
-        $this->_handleMagicFolder([$this, '_precacheForce']);
-        $this->_handleMagicFolder([$this, '_precache']);
+        $force = $this->option('force');
+        if ($force) {
+            $this->_handleMagicFolder([$this, '_precacheForce']);
+        } else {
+            $this->_handleMagicFolder([$this, '_precache']);
+        }
     }
 
     /**
index 050295aa6416f1e81bc2c47119c905768ad64e69..2a42eedfb7681c0a472124e35b9cb8ae255027c2 100644 (file)
@@ -2,7 +2,37 @@
 
 namespace Cubist\Backpack\Jobs;
 
+use Illuminate\Support\Facades\Artisan;
+
 class ModelsPrecache extends Base
 {
+    /**
+     * @var bool
+     */
+    protected $force = false;
+
+    /**
+     * @param bool $force
+     */
+    public function setForce(bool $force): void
+    {
+        $this->force = $force;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isForce(): bool
+    {
+        return $this->force;
+    }
 
+    public function handle()
+    {
+        $args = [];
+        if ($this->isForce()) {
+            $args['--force'] = true;
+        }
+        Artisan::call('cubist:magic:precache', $args);
+    }
 }