From b2c96a1b164c37320c99c02f414b0c6fa8a84645 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Mon, 4 Apr 2016 21:00:04 +0900 Subject: [PATCH] Use existing ClientController classes to remove compiled assets Refs #837. --- .../src/Debug/Console/CacheClearCommand.php | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/framework/core/src/Debug/Console/CacheClearCommand.php b/framework/core/src/Debug/Console/CacheClearCommand.php index aebff46e0..bbd34b5a7 100644 --- a/framework/core/src/Debug/Console/CacheClearCommand.php +++ b/framework/core/src/Debug/Console/CacheClearCommand.php @@ -10,7 +10,9 @@ namespace Flarum\Debug\Console; +use Flarum\Admin\Controller\ClientController as AdminClient; use Flarum\Console\Command\AbstractCommand; +use Flarum\Forum\Controller\ClientController as ForumClient; use Illuminate\Contracts\Cache\Store; class CacheClearCommand extends AbstractCommand @@ -20,9 +22,21 @@ class CacheClearCommand extends AbstractCommand */ protected $cache; - public function __construct(Store $cache) + /** + * @var \Flarum\Forum\Controller\ClientController + */ + protected $forum; + + /** + * @var \Flarum\Admin\Controller\ClientController + */ + protected $admin; + + public function __construct(Store $cache, ForumClient $forum, AdminClient $admin) { $this->cache = $cache; + $this->forum = $forum; + $this->admin = $admin; parent::__construct(); } @@ -44,22 +58,9 @@ class CacheClearCommand extends AbstractCommand { $this->info('Clearing the cache...'); - $this->removeFilesMatching('assets', '*.js'); - $this->removeFilesMatching('assets', '*.css'); + $this->forum->flushAssets(); + $this->admin->flushAssets(); $this->cache->flush(); } - - protected function removeFilesMatching($path, $pattern) - { - $this->info("Removing $pattern files in $path..."); - - $path = $this->getPath($path); - array_map('unlink', glob("$path/$pattern")); - } - - protected function getPath($path) - { - return base_path($path); - } }