feat: add cache:clear CLI command for module cache clearing (#46)
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Console\ApplicationFactory;
|
use Console\ApplicationFactory;
|
||||||
|
use Console\Commands\CacheClearCommand;
|
||||||
use Console\Commands\CustomerCountsCommand;
|
use Console\Commands\CustomerCountsCommand;
|
||||||
use Console\Commands\PulseSendEventsCommand;
|
use Console\Commands\PulseSendEventsCommand;
|
||||||
use Console\Commands\ScheduleListCommand;
|
use Console\Commands\ScheduleListCommand;
|
||||||
@@ -99,5 +100,6 @@ $console->add($app->get(ScheduleListCommand::class));
|
|||||||
$console->add($app->get(PulseSendEventsCommand::class));
|
$console->add($app->get(PulseSendEventsCommand::class));
|
||||||
$console->add($app->get(ImagesWarmupCacheCommand::class));
|
$console->add($app->get(ImagesWarmupCacheCommand::class));
|
||||||
$console->add($app->get(ImagesCacheClearCommand::class));
|
$console->add($app->get(ImagesCacheClearCommand::class));
|
||||||
|
$console->add($app->get(CacheClearCommand::class));
|
||||||
$console->add($app->get(CustomerCountsCommand::class));
|
$console->add($app->get(CustomerCountsCommand::class));
|
||||||
$console->run();
|
$console->run();
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Console\Commands;
|
||||||
|
|
||||||
|
use Openguru\OpenCartFramework\Cache\CacheInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
|
class CacheClearCommand extends TeleCartCommand
|
||||||
|
{
|
||||||
|
protected static $defaultName = 'cache:clear';
|
||||||
|
protected static $defaultDescription = 'Очистка кеша модуля TeleCart';
|
||||||
|
|
||||||
|
private CacheInterface $cache;
|
||||||
|
|
||||||
|
public function __construct(CacheInterface $cache)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->cache = $cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
$io->title('Очистка кеша модуля TeleCart');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->cache->clear();
|
||||||
|
$io->success('Кеш успешно очищен!');
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$io->error('Ошибка при очистке кеша: ' . $e->getMessage());
|
||||||
|
|
||||||
|
return Command::FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user