Files
sterivein/core/lib/Thelia/Command/ClearCacheCommand.php
2013-06-03 13:12:34 +02:00

55 lines
2.8 KiB
PHP

<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOException;
class ClearCacheCommand extends Command
{
protected function configure()
{
$this
->setName("clear:cache")
->setDescription("Invalidate all caches");
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$cacheDir = $this->getApplication()->getContainer()->getParameter("kernel.cache_dir");
if (!is_writable($cacheDir)) {
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $cacheDir));
}
$fs = new Filesystem();
$fs->remove($this->getApplication()->getKernel()->getContainer()->getParameter("kernel.cache_dir"));
}
}