Version 1
[yaffs-website] / web / core / modules / shortcut / src / ShortcutSetListBuilder.php
diff --git a/web/core/modules/shortcut/src/ShortcutSetListBuilder.php b/web/core/modules/shortcut/src/ShortcutSetListBuilder.php
new file mode 100644 (file)
index 0000000..2cc582e
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+namespace Drupal\shortcut;
+
+use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
+use Drupal\Core\Entity\EntityInterface;
+
+/**
+ * Defines a class to build a listing of shortcut set entities.
+ *
+ * @see \Drupal\shortcut\Entity\ShortcutSet
+ */
+class ShortcutSetListBuilder extends ConfigEntityListBuilder {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildHeader() {
+    $header['name'] = t('Name');
+    return $header + parent::buildHeader();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDefaultOperations(EntityInterface $entity) {
+    $operations = parent::getDefaultOperations($entity);
+
+    if (isset($operations['edit'])) {
+      $operations['edit']['title'] = t('Edit shortcut set');
+    }
+
+    $operations['list'] = [
+      'title' => t('List links'),
+      'url' => $entity->urlInfo('customize-form'),
+    ];
+    return $operations;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildRow(EntityInterface $entity) {
+    $row['name'] = $entity->label();
+    return $row + parent::buildRow($entity);
+  }
+
+}