clear cache files from storage/views (#2648)

Co-authored-by: Emamul Khan <emamul.khan@oxid-esales.com>
This commit is contained in:
Emamul Khan 2021-03-01 22:45:19 +01:00 committed by GitHub
parent f0c6050654
commit 7fa22a131f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -10,10 +10,11 @@
namespace Flarum\Extend; namespace Flarum\Extend;
use Flarum\Extension\Extension; use Flarum\Extension\Extension;
use Flarum\Foundation\Paths;
use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
class View implements ExtenderInterface class View implements ExtenderInterface, LifecycleInterface
{ {
private $namespaces = []; private $namespaces = [];
@ -48,4 +49,26 @@ class View implements ExtenderInterface
} }
}); });
} }
/**
* @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/*'));
}
} }

View File

@ -60,6 +60,7 @@ class CacheClearCommand extends AbstractCommand
$storagePath = $this->paths->storage; $storagePath = $this->paths->storage;
array_map('unlink', glob($storagePath.'/formatter/*')); array_map('unlink', glob($storagePath.'/formatter/*'));
array_map('unlink', glob($storagePath.'/locale/*')); array_map('unlink', glob($storagePath.'/locale/*'));
array_map('unlink', glob($storagePath.'/views/*'));
event(new ClearingCache); event(new ClearingCache);
} }