mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 12:33:17 +08:00
parent
37d7f315d3
commit
8e35afe204
48
src/Console/Command/CacheClearCommand.php
Normal file
48
src/Console/Command/CacheClearCommand.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Console\Command;
|
||||
|
||||
class CacheClearCommand extends AbstractCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('cache:clear')
|
||||
->setDescription('Remove all temporary and generated files');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function fire()
|
||||
{
|
||||
$this->info('Clearing the cache...');
|
||||
|
||||
$this->removeFilesMatching('assets', '*.js');
|
||||
$this->removeFilesMatching('assets', '*.css');
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Flarum\Console;
|
||||
|
||||
use Flarum\Console\Command\CacheClearCommand;
|
||||
use Flarum\Console\Command\GenerateExtensionCommand;
|
||||
use Flarum\Console\Command\GenerateMigrationCommand;
|
||||
use Flarum\Debug\Console\InfoCommand;
|
||||
|
@ -42,6 +43,7 @@ class Server extends AbstractServer
|
|||
InstallCommand::class,
|
||||
MigrateCommand::class,
|
||||
InfoCommand::class,
|
||||
CacheClearCommand::class,
|
||||
GenerateExtensionCommand::class,
|
||||
GenerateMigrationCommand::class,
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue
Block a user