From: Vincent Vanwaelscappel Date: Thu, 16 Jun 2022 10:59:34 +0000 (+0200) Subject: wip #4210 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d430d6369d5cdd34830ed0624afb549158baee73;p=cubist_cms-back.git wip #4210 --- diff --git a/src/app/Console/Commands/PrecacheCommand.php b/src/app/Console/Commands/PrecacheCommand.php index 967539e..c1d3e2a 100644 --- a/src/app/Console/Commands/PrecacheCommand.php +++ b/src/app/Console/Commands/PrecacheCommand.php @@ -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']); + } } /** diff --git a/src/app/Jobs/ModelsPrecache.php b/src/app/Jobs/ModelsPrecache.php index 050295a..2a42eed 100644 --- a/src/app/Jobs/ModelsPrecache.php +++ b/src/app/Jobs/ModelsPrecache.php @@ -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); + } }