Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / media / src / MediaTypeListBuilder.php
1 <?php
2
3 namespace Drupal\media;
4
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
7 use Drupal\Core\Url;
8
9 /**
10  * Provides a listing of media types.
11  */
12 class MediaTypeListBuilder extends ConfigEntityListBuilder {
13
14   /**
15    * {@inheritdoc}
16    */
17   public function buildHeader() {
18     $header['title'] = $this->t('Name');
19     $header['description'] = [
20       'data' => $this->t('Description'),
21       'class' => [RESPONSIVE_PRIORITY_MEDIUM],
22     ];
23     return $header + parent::buildHeader();
24   }
25
26   /**
27    * {@inheritdoc}
28    */
29   public function buildRow(EntityInterface $entity) {
30     $row['title'] = [
31       'data' => $entity->label(),
32       'class' => ['menu-label'],
33     ];
34     $row['description']['data'] = ['#markup' => $entity->getDescription()];
35     return $row + parent::buildRow($entity);
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function render() {
42     $build = parent::render();
43     $build['table']['#empty'] = $this->t('No media types available. <a href=":url">Add media type</a>.', [
44       ':url' => Url::fromRoute('entity.media_type.add_form')->toString(),
45     ]);
46     return $build;
47   }
48
49 }