Version 1
[yaffs-website] / web / modules / contrib / media_entity / src / MediaBundleListBuilder.php
diff --git a/web/modules/contrib/media_entity/src/MediaBundleListBuilder.php b/web/modules/contrib/media_entity/src/MediaBundleListBuilder.php
new file mode 100644 (file)
index 0000000..e5158b1
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+namespace Drupal\media_entity;
+
+use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
+use Drupal\Core\Entity\EntityHandlerInterface;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Component\Utility\Xss;
+use Drupal\Core\Url;
+
+/**
+ * Provides a listing of media bundles.
+ */
+class MediaBundleListBuilder extends ConfigEntityListBuilder implements EntityHandlerInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildHeader() {
+    $header['title'] = $this->t('Name');
+    $header['description'] = [
+      'data' => $this->t('Description'),
+      'class' => [RESPONSIVE_PRIORITY_MEDIUM],
+    ];
+    return $header + parent::buildHeader();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildRow(EntityInterface $entity) {
+    $row['title'] = [
+      'data' => $entity->label(),
+      'class' => ['menu-label'],
+    ];
+    $row['description'] = Xss::filterAdmin($entity->getDescription());
+    return $row + parent::buildRow($entity);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function render() {
+    $build = parent::render();
+    $build['#empty'] = $this->t('No media bundle available. <a href="@link">Add media bundle</a>.', [
+      '@link' => Url::fromRoute('entity.media_bundle.add_form')->toString(),
+    ]);
+    return $build;
+  }
+
+}