Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Helper / OutputHandler.php
diff --git a/vendor/chi-teck/drupal-code-generator/src/Helper/OutputHandler.php b/vendor/chi-teck/drupal-code-generator/src/Helper/OutputHandler.php
new file mode 100644 (file)
index 0000000..f0b628c
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+namespace DrupalCodeGenerator\Helper;
+
+use Symfony\Component\Console\Helper\Helper;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Output printer for generators.
+ */
+class OutputHandler extends Helper {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getName() {
+    return 'dcg_output_handler';
+  }
+
+  /**
+   * Prints summary.
+   *
+   * @param \Symfony\Component\Console\Output\OutputInterface $output
+   *   Output instance.
+   * @param array $dumped_files
+   *   List of created or updated files.
+   */
+  public function printSummary(OutputInterface $output, array $dumped_files) {
+
+    if (count($dumped_files) > 0) {
+      // Multiple hooks can be dumped to the same file.
+      $dumped_files = array_unique($dumped_files);
+
+      usort($dumped_files, function ($a, $b) {
+        $depth_a = substr_count($a, '/');
+        $depth_b = substr_count($b, '/');
+        // Top level files should be printed first.
+        return $depth_a == $depth_b || ($depth_a > 1 && $depth_b > 1) ?
+          strcmp($a, $b) : ($depth_a > $depth_b ? 1 : -1);
+      });
+
+      $output->writeln('');
+      $output->writeln(' The following directories and files have been created or updated:');
+      $output->writeln('<fg=cyan;options=bold>–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––</>');
+      foreach ($dumped_files as $file) {
+        $output->writeln(" • $file");
+      }
+      $output->writeln('');
+    }
+
+  }
+
+}