mirror of
https://github.com/flarum/core.git
synced 2025-07-25 18:51:40 +02:00
48
framework/core/src/Console/Command/CacheClearCommand.php
Normal file
48
framework/core/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;
|
namespace Flarum\Console;
|
||||||
|
|
||||||
|
use Flarum\Console\Command\CacheClearCommand;
|
||||||
use Flarum\Console\Command\GenerateExtensionCommand;
|
use Flarum\Console\Command\GenerateExtensionCommand;
|
||||||
use Flarum\Console\Command\GenerateMigrationCommand;
|
use Flarum\Console\Command\GenerateMigrationCommand;
|
||||||
use Flarum\Debug\Console\InfoCommand;
|
use Flarum\Debug\Console\InfoCommand;
|
||||||
@@ -42,6 +43,7 @@ class Server extends AbstractServer
|
|||||||
InstallCommand::class,
|
InstallCommand::class,
|
||||||
MigrateCommand::class,
|
MigrateCommand::class,
|
||||||
InfoCommand::class,
|
InfoCommand::class,
|
||||||
|
CacheClearCommand::class,
|
||||||
GenerateExtensionCommand::class,
|
GenerateExtensionCommand::class,
|
||||||
GenerateMigrationCommand::class,
|
GenerateMigrationCommand::class,
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user