From 1568f9c29b8507064bdea577a1b85a2dc9c9bf48 Mon Sep 17 00:00:00 2001 From: Emamul Khan Date: Mon, 1 Mar 2021 19:18:22 +0100 Subject: [PATCH] clear cache files from storage/views --- src/Extend/View.php | 25 +++++++++++++++++++- src/Foundation/Console/CacheClearCommand.php | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Extend/View.php b/src/Extend/View.php index fd00ba2f64..8850d96db7 100644 --- a/src/Extend/View.php +++ b/src/Extend/View.php @@ -10,10 +10,11 @@ namespace Flarum\Extend; use Flarum\Extension\Extension; +use Flarum\Foundation\Paths; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\View\Factory; -class View implements ExtenderInterface +class View implements ExtenderInterface, LifecycleInterface { private $namespaces = []; @@ -48,4 +49,26 @@ public function extend(Container $container, Extension $extension = null) } }); } + + /** + * @param Container $container + * @param Extension $extension + * @throws \Illuminate\Contracts\Container\BindingResolutionException + */ + public function onEnable(Container $container, Extension $extension) + { + $storagePath = $container->make(Paths::class)->storage; + array_map('unlink', glob($storagePath.'/views/*')); + } + + /** + * @param Container $container + * @param Extension $extension + * @throws \Illuminate\Contracts\Container\BindingResolutionException + */ + public function onDisable(Container $container, Extension $extension) + { + $storagePath = $container->make(Paths::class)->storage; + array_map('unlink', glob($storagePath.'/views/*')); + } } diff --git a/src/Foundation/Console/CacheClearCommand.php b/src/Foundation/Console/CacheClearCommand.php index 1229f74fa5..5659976b21 100644 --- a/src/Foundation/Console/CacheClearCommand.php +++ b/src/Foundation/Console/CacheClearCommand.php @@ -60,6 +60,7 @@ protected function fire() $storagePath = $this->paths->storage; array_map('unlink', glob($storagePath.'/formatter/*')); array_map('unlink', glob($storagePath.'/locale/*')); + array_map('unlink', glob($storagePath.'/views/*')); event(new ClearingCache); }