629a1fbe1ddcf9f6dc18c866ac2711d26fa2e455
[yaffs-website] / web / modules / contrib / embed / src / EmbedButtonListBuilder.php
1 <?php
2
3 namespace Drupal\embed;
4
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
7
8 /**
9  * Provides a listing of all Embed Button entities.
10  */
11 class EmbedButtonListBuilder extends ConfigEntityListBuilder {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function buildHeader() {
17     $header = [];
18     $header['label'] = $this->t('Embed button');
19     $header['embed_type'] = $this->t('Embed type');
20     $header['icon'] = [
21       'data' => $this->t('Icon'),
22       'class' => [RESPONSIVE_PRIORITY_LOW],
23     ];
24     return $header + parent::buildHeader();
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function buildRow(EntityInterface $entity) {
31     /** @var \Drupal\embed\EmbedButtonInterface $entity */
32     $row = [];
33     $row['label'] = $entity->label();
34     $row['embed_type'] = $entity->getTypeLabel();
35     if ($icon_url = $entity->getIconUrl()) {
36       $row['icon']['data'] = [
37         '#theme' => 'image',
38         '#uri' => $icon_url,
39         '#alt' => $this->t('Icon for the @label button.', ['@label' => $entity->label()]),
40       ];
41     }
42     else {
43       $row['icon'] = $this->t('None');
44     }
45
46     return $row + parent::buildRow($entity);
47   }
48
49 }