3 namespace DrupalCodeGenerator\Helper;
5 use Symfony\Component\Console\Helper\Helper;
6 use Symfony\Component\Console\Output\OutputInterface;
9 * Output printer for generators.
11 class OutputHandler extends Helper {
16 public function getName() {
17 return 'dcg_output_handler';
23 * @param \Symfony\Component\Console\Output\OutputInterface $output
25 * @param array $dumped_files
26 * List of created or updated files.
28 public function printSummary(OutputInterface $output, array $dumped_files) {
30 if (count($dumped_files) > 0) {
31 // Multiple hooks can be dumped to the same file.
32 $dumped_files = array_unique($dumped_files);
34 usort($dumped_files, function ($a, $b) {
35 $depth_a = substr_count($a, '/');
36 $depth_b = substr_count($b, '/');
37 // Top level files should be printed first.
38 return $depth_a == $depth_b || ($depth_a > 1 && $depth_b > 1) ?
39 strcmp($a, $b) : ($depth_a > $depth_b ? 1 : -1);
43 $output->writeln(' The following directories and files have been created or updated:');
44 $output->writeln('<fg=cyan;options=bold>–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</>');
45 foreach ($dumped_files as $file) {
46 $output->writeln(" • $file");