Version 1
[yaffs-website] / web / modules / contrib / entity_browser / src / Controllers / EntityBrowserListBuilder.php
diff --git a/web/modules/contrib/entity_browser/src/Controllers/EntityBrowserListBuilder.php b/web/modules/contrib/entity_browser/src/Controllers/EntityBrowserListBuilder.php
new file mode 100644 (file)
index 0000000..fe7d7c3
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+namespace Drupal\entity_browser\Controllers;
+
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Entity\EntityListBuilder;
+
+/**
+ * Provides a list controller for entity browser.
+ *
+ * @ingroup entity_browser
+ */
+class EntityBrowserListBuilder extends EntityListBuilder {
+
+  /**
+   * {@inheritdoc}
+   *
+   * Building the header and content lines for the entity browser list.
+   *
+   * Calling the parent::buildHeader() adds a column for the possible actions
+   * and inserts the 'edit' and 'delete' links as defined for the entity type.
+   */
+  public function buildHeader() {
+    $header['id'] = $this->t('ID');
+    $header['name'] = $this->t('Name');
+    return $header + parent::buildHeader();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildRow(EntityInterface $entity) {
+    /* @var $entity \Drupal\entity_browser\Entity\EntityBrowser */
+    $row['id'] = $entity->id();
+    $row['name'] = $entity->label();
+    return $row + parent::buildRow($entity);
+  }
+
+}