You are here

private function LintCommand::displayTxt in Twig Tweak 3.x

Same name and namespace in other branches
  1. 3.1.x src/Command/LintCommand.php \Drupal\twig_tweak\Command\LintCommand::displayTxt()
1 call to LintCommand::displayTxt()
LintCommand::display in src/Command/LintCommand.php

File

src/Command/LintCommand.php, line 184

Class

LintCommand
Command that will validate your template syntax and output encountered errors.

Namespace

Drupal\twig_tweak\Command

Code

private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $filesInfo) {
  $errors = 0;
  foreach ($filesInfo as $info) {
    if ($info['valid'] && $output
      ->isVerbose()) {
      $io
        ->comment('<info>OK</info>' . ($info['file'] ? sprintf(' in %s', $info['file']) : ''));
    }
    elseif (!$info['valid']) {
      ++$errors;
      $this
        ->renderException($io, $info['template'], $info['exception'], $info['file']);
    }
  }
  if (0 === $errors) {
    $io
      ->success(sprintf('All %d Twig files contain valid syntax.', \count($filesInfo)));
  }
  else {
    $io
      ->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', \count($filesInfo) - $errors, $errors));
  }
  return min($errors, 1);
}