Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / module / plugin-manager / model.drush.inc.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/module/plugin-manager/model.drush.inc.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/module/plugin-manager/model.drush.inc.twig
new file mode 100644 (file)
index 0000000..e7cabc0
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * @file
+ * Drush integration for {{ name }} module.
+ */
+
+/**
+ * Implements hook_drush_command().
+ */
+function {{ machine_name }}_drush_command() {
+  $items['{{ machine_name }}-list'] = [
+    'description' => 'Show a list of available {{ name|plural|lower }}.',
+  ];
+  return $items;
+}
+
+/**
+ * Callback function for {{ machine_name }}-list command.
+ */
+function drush_{{ machine_name }}_list() {
+  $plugin_manager = Drupal::service('plugin.manager.{{ machine_name }}');
+
+  $rows[] = [
+    'ID',
+    'Label',
+    'Description',
+    'Method 1',
+    'Method 2',
+    'Method 3',
+  ];
+
+  foreach ($plugin_manager->getDefinitions() as $definition) {
+    ${{ machine_name }} = $plugin_manager->createInstance($definition['id']);
+    $rows[] = [
+      $definition['id'],
+      $definition['label'],
+      $definition['description'],
+      ${{ machine_name }}->method1(),
+      ${{ machine_name }}->method2(),
+      ${{ machine_name }}->method3(),
+    ];
+  }
+
+  drush_print_table($rows);
+}