Version 1
[yaffs-website] / web / core / modules / comment / src / CommentTypeListBuilder.php
diff --git a/web/core/modules/comment/src/CommentTypeListBuilder.php b/web/core/modules/comment/src/CommentTypeListBuilder.php
new file mode 100644 (file)
index 0000000..53bf4c9
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+
+namespace Drupal\comment;
+
+use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
+use Drupal\Core\Entity\EntityInterface;
+
+/**
+ * Defines a class to build a listing of comment type entities.
+ *
+ * @see \Drupal\comment\Entity\CommentType
+ */
+class CommentTypeListBuilder extends ConfigEntityListBuilder {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDefaultOperations(EntityInterface $entity) {
+    $operations = parent::getDefaultOperations($entity);
+    // Place the edit operation after the operations added by field_ui.module
+    // which have the weights 15, 20, 25.
+    if (isset($operations['edit'])) {
+      $operations['edit']['weight'] = 30;
+    }
+    return $operations;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildHeader() {
+    $header['type'] = t('Comment type');
+    $header['description'] = t('Description');
+    return $header + parent::buildHeader();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildRow(EntityInterface $entity) {
+    $row['type'] = $entity->label();
+    $row['description']['data'] = ['#markup' => $entity->getDescription()];
+    return $row + parent::buildRow($entity);
+  }
+
+}