private function LintCommand::displayJson in Twig Tweak 3.1.x
Same name and namespace in other branches
- 3.x src/Command/LintCommand.php \Drupal\twig_tweak\Command\LintCommand::displayJson()
1 call to LintCommand::displayJson()
- LintCommand::display in src/
Command/ LintCommand.php
File
- src/
Command/ LintCommand.php, line 206
Class
- LintCommand
- Command that will validate your template syntax and output encountered errors.
Namespace
Drupal\twig_tweak\CommandCode
private function displayJson(OutputInterface $output, array $filesInfo) {
$errors = 0;
array_walk($filesInfo, function (&$v) use (&$errors) {
$v['file'] = (string) $v['file'];
unset($v['template']);
if (!$v['valid']) {
$v['message'] = $v['exception']
->getMessage();
unset($v['exception']);
++$errors;
}
});
$output
->writeln(json_encode($filesInfo, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
return min($errors, 1);
}