Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / media / src / MediaTypeListBuilder.php
diff --git a/web/core/modules/media/src/MediaTypeListBuilder.php b/web/core/modules/media/src/MediaTypeListBuilder.php
new file mode 100644 (file)
index 0000000..e8d79da
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+namespace Drupal\media;
+
+use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Url;
+
+/**
+ * Provides a listing of media types.
+ */
+class MediaTypeListBuilder extends ConfigEntityListBuilder {
+
+  /**
+   * {@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']['data'] = ['#markup' => $entity->getDescription()];
+    return $row + parent::buildRow($entity);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function render() {
+    $build = parent::render();
+    $build['table']['#empty'] = $this->t('No media types available. <a href=":url">Add media type</a>.', [
+      ':url' => Url::fromRoute('entity.media_type.add_form')->toString(),
+    ]);
+    return $build;
+  }
+
+}