[TwigBundle] Fix return code in LintComand

This commit is contained in:
alexandresalome 2012-06-06 21:11:24 +02:00
parent 604a79aba2
commit df5590ec60

View File

@ -87,14 +87,18 @@ EOF
$files = Finder::create()->files()->in($dir)->name('*.twig'); $files = Finder::create()->files()->in($dir)->name('*.twig');
} }
$error = false;
foreach ($files as $file) { foreach ($files as $file) {
try { try {
$twig->parse($twig->tokenize(file_get_contents($file), (string) $file)); $twig->parse($twig->tokenize(file_get_contents($file), (string) $file));
$output->writeln(sprintf("<info>OK</info> in %s", $file)); $output->writeln(sprintf("<info>OK</info> in %s", $file));
} catch (\Twig_Error $e) { } catch (\Twig_Error $e) {
$this->renderException($output, $file, $e); $this->renderException($output, $file, $e);
$error = true;
} }
} }
return $error ? 1 : 0;
} }
protected function renderException(OutputInterface $output, $file, \Twig_Error $exception) protected function renderException(OutputInterface $output, $file, \Twig_Error $exception)