1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-06 13:16:45 +02:00

feat(console): improve cache console commands logic

This commit is contained in:
Awilum
2022-05-01 19:51:44 +03:00
parent 1d5685c303
commit fe1ca849ae
3 changed files with 14 additions and 6 deletions

View File

@@ -19,7 +19,6 @@ namespace Flextype\Console\Commands\Cache;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Console\Input\InputOption;
use function Thermage\div;
use function Thermage\renderToString;
@@ -34,8 +33,6 @@ class CacheClearCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$path = PATH['tmp'];
if (filesystem()->directory($path)->exists()) {

View File

@@ -19,7 +19,6 @@ namespace Flextype\Console\Commands\Cache;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Console\Input\InputOption;
use function Thermage\div;
use function Thermage\renderToString;
@@ -34,8 +33,6 @@ class CacheClearConfigCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$configPath = PATH['tmp'] . '/config';
if (filesystem()->directory($configPath)->exists()) {

View File

@@ -20,6 +20,8 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use function Thermage\div;
use function Thermage\renderToString;
class CacheDeleteCommand extends Command
{
@@ -36,9 +38,21 @@ class CacheDeleteCommand extends Command
if (cache()->delete($key)) {
$io->success('Cache item with key ' . $key . ' deleted.');
$output->write(
renderToString(
div('Success: Cache item with key ' . $key . ' created.',
'bg-success px-2 py-1')
)
);
return Command::SUCCESS;
} else {
$io->error('Cache item with key ' . $key . ' wasn\'t deleted.');
$output->write(
renderToString(
div('Success: Cache item with key ' . $key . ' created.',
'bg-success px-2 py-1')
)
);
return Command::FAILURE;
}
}