summaryrefslogtreecommitdiffstats
path: root/core/modules/media/src/MediaTypeListBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/media/src/MediaTypeListBuilder.php')
-rw-r--r--core/modules/media/src/MediaTypeListBuilder.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/modules/media/src/MediaTypeListBuilder.php b/core/modules/media/src/MediaTypeListBuilder.php
new file mode 100644
index 0000000..e8d79da
--- /dev/null
+++ b/core/modules/media/src/MediaTypeListBuilder.php
@@ -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;
+ }
+
+}