Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / module / configuration-entity / src / ExampleListBuilder.php.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/module/configuration-entity/src/ExampleListBuilder.php.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/module/configuration-entity/src/ExampleListBuilder.php.twig
new file mode 100644 (file)
index 0000000..8de78d5
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\{{ machine_name }};
+
+use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
+use Drupal\Core\Entity\EntityInterface;
+
+/**
+ * Provides a listing of {{ entity_type_label|lower|plural }}.
+ */
+class {{ class_prefix }}ListBuilder extends ConfigEntityListBuilder {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildHeader() {
+    $header['label'] = $this->t('Label');
+    $header['id'] = $this->t('Machine name');
+    $header['status'] = $this->t('Status');
+    return $header + parent::buildHeader();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildRow(EntityInterface $entity) {
+    /** @var \Drupal\{{ machine_name }}\{{ class_prefix }}Interface $entity */
+    $row['label'] = $entity->label();
+    $row['id'] = $entity->id();
+    $row['status'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
+    return $row + parent::buildRow($entity);
+  }
+
+}