mirror of
https://github.com/flarum/framework.git
synced 2025-04-09 00:00:27 +08:00
Use existing ClientController classes to remove compiled assets
Refs #837.
This commit is contained in:
parent
558ae880a6
commit
b2c96a1b16
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
namespace Flarum\Debug\Console;
|
namespace Flarum\Debug\Console;
|
||||||
|
|
||||||
|
use Flarum\Admin\Controller\ClientController as AdminClient;
|
||||||
use Flarum\Console\Command\AbstractCommand;
|
use Flarum\Console\Command\AbstractCommand;
|
||||||
|
use Flarum\Forum\Controller\ClientController as ForumClient;
|
||||||
use Illuminate\Contracts\Cache\Store;
|
use Illuminate\Contracts\Cache\Store;
|
||||||
|
|
||||||
class CacheClearCommand extends AbstractCommand
|
class CacheClearCommand extends AbstractCommand
|
||||||
@ -20,9 +22,21 @@ class CacheClearCommand extends AbstractCommand
|
|||||||
*/
|
*/
|
||||||
protected $cache;
|
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->cache = $cache;
|
||||||
|
$this->forum = $forum;
|
||||||
|
$this->admin = $admin;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
@ -44,22 +58,9 @@ class CacheClearCommand extends AbstractCommand
|
|||||||
{
|
{
|
||||||
$this->info('Clearing the cache...');
|
$this->info('Clearing the cache...');
|
||||||
|
|
||||||
$this->removeFilesMatching('assets', '*.js');
|
$this->forum->flushAssets();
|
||||||
$this->removeFilesMatching('assets', '*.css');
|
$this->admin->flushAssets();
|
||||||
|
|
||||||
$this->cache->flush();
|
$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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user