complete cache:clear command
This commit is contained in:
4
Thelia
4
Thelia
@@ -10,8 +10,8 @@ use Thelia\Core\Application;
|
|||||||
use Symfony\Component\Console\Input\ArgvInput;
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
|
|
||||||
$input = new ArgvInput();
|
$input = new ArgvInput();
|
||||||
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
|
$env = $input->getParameterOption(array('--env', '-e'), getenv('THELIA_ENV') ?: 'dev');
|
||||||
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
|
$debug = getenv('THELIA_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
|
||||||
|
|
||||||
$thelia = new Thelia($env, $debug);
|
$thelia = new Thelia($env, $debug);
|
||||||
$application = new Application($thelia);
|
$application = new Application($thelia);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class ClearCacheCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName("clear:cache")
|
->setName("cache:clear")
|
||||||
->setDescription("Invalidate all caches");
|
->setDescription("Invalidate all caches");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,16 @@ class ClearCacheCommand extends Command
|
|||||||
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $cacheDir));
|
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $cacheDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("Clearing cache in <info>%s</info> directory", $cacheDir));
|
||||||
|
|
||||||
$fs = new Filesystem();
|
$fs = new Filesystem();
|
||||||
$fs->remove($this->getApplication()->getKernel()->getContainer()->getParameter("kernel.cache_dir"));
|
try {
|
||||||
|
$fs->remove($cacheDir);
|
||||||
|
|
||||||
|
$output->writeln("<info>cache clear successfully</info>");
|
||||||
|
} catch(IOException $e) {
|
||||||
|
$output->writeln(sprintf("error during clearing cache : %s", $e->getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,9 @@ class Application extends BaseApplication
|
|||||||
$this->kernel = $kernel;
|
$this->kernel = $kernel;
|
||||||
|
|
||||||
parent::__construct("Thelia", Thelia::THELIA_VERSION);
|
parent::__construct("Thelia", Thelia::THELIA_VERSION);
|
||||||
|
|
||||||
|
$this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
|
||||||
|
$this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKernel()
|
public function getKernel()
|
||||||
|
|||||||
Reference in New Issue
Block a user