Skip to content

Commit

Permalink
Merge branch 'release/0.0.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
hswong3i committed Oct 16, 2014
2 parents 6d6ce6e + 1be32ff commit 79cdcc7
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions app/console
Expand Up @@ -24,6 +24,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\ProcessBuilder;
Expand All @@ -42,14 +43,40 @@ $input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), 'dev');
$debug = !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';

$app = new Silex\Application(array('env' => $env));
require __DIR__ . '/AppKernel.php';
if ($debug) {
Debug::enable();
$app['debug'] = true;
}
else {
$app['debug'] = false;
}

$app = new Silex\Application(array('env' => $env));
require __DIR__ . '/AppKernel.php';
$app->boot();

$console
->register('cache:clear')
->setName('cache:clear')
->setDescription('Clears the cache')
->setHelp(<<<EOT
The <info>%command.name%</info> command clears the application cache for a given environment
and debug mode:
<info>php %command.full_name% --env=dev</info>
<info>php %command.full_name% --env=prod --no-debug</info>
EOT
)
->setCode(function (InputInterface $input, OutputInterface $output) use ($app) {
$finder = Finder::create()->in(__DIR__.'/cache/'.$app['env']);
$fs = new Filesystem();
try {
$output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $app['env'], var_export($app['debug'], true)));
$fs->remove($finder);
} catch (IOExceptionInterface $e) {
echo "An error occurred while creating your directory at ".$e->getPath();
}
});

$console
->register('doctrine:database:drop')
->setName('doctrine:database:drop')
Expand Down

0 comments on commit 79cdcc7

Please sign in to comment.