File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Statamic \Console \Commands ;
4+
5+ use Illuminate \Console \Command ;
6+ use Statamic \Assets \Asset ;
7+ use Statamic \Assets \AssetContainerContents ;
8+ use Statamic \Console \RunsInPlease ;
9+
10+ use function Laravel \Prompts \spin ;
11+
12+ class AssetsCacheClear extends Command
13+ {
14+ use RunsInPlease;
15+
16+ /**
17+ * The name and signature of the console command.
18+ *
19+ * @var string
20+ */
21+ protected $ signature = 'statamic:assets:clear-cache ' ;
22+
23+ /**
24+ * The console command description.
25+ *
26+ * @var string
27+ */
28+ protected $ description = 'Clear the asset meta and folder cache ' ;
29+
30+ /**
31+ * Execute the console command.
32+ *
33+ * @return void
34+ */
35+ public function handle ()
36+ {
37+ if (! config ()->has ('cache.stores.asset_meta ' ) && ! config ()->has ('cache.stores.asset_container_contents ' )) {
38+ $ this ->components ->error ('You do not have any custom asset cache stores. ' );
39+
40+ return 0 ;
41+ }
42+
43+ if (config ()->has ('cache.stores.asset_meta ' )) {
44+ spin (callback: fn () => Asset::make ()->cacheStore ()->flush (), message: 'Clearing the asset meta cache... ' );
45+
46+ $ this ->components ->info ('Your asset meta cache is now so very, very empty. ' );
47+ }
48+
49+ if (config ()->has ('cache.stores.asset_container_contents ' )) {
50+ spin (callback: fn () => (new AssetContainerContents )->cacheStore ()->flush (), message: 'Clearing the asset folder cache... ' );
51+
52+ $ this ->components ->info ('Your asset folder cache is now so very, very empty. ' );
53+ }
54+ }
55+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class ConsoleServiceProvider extends ServiceProvider
1111 protected $ commands = [
1212 Commands \ListCommand::class,
1313 Commands \AddonsDiscover::class,
14+ Commands \AssetsCacheClear::class,
1415 Commands \AssetsGeneratePresets::class,
1516 Commands \AssetsMeta::class,
1617 Commands \GlideClear::class,
You can’t perform that action at this time.
0 commit comments