Version 1
[yaffs-website] / web / modules / contrib / embed / src / EmbedButtonListBuilder.php
diff --git a/web/modules/contrib/embed/src/EmbedButtonListBuilder.php b/web/modules/contrib/embed/src/EmbedButtonListBuilder.php
new file mode 100644 (file)
index 0000000..629a1fb
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+namespace Drupal\embed;
+
+use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
+use Drupal\Core\Entity\EntityInterface;
+
+/**
+ * Provides a listing of all Embed Button entities.
+ */
+class EmbedButtonListBuilder extends ConfigEntityListBuilder {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildHeader() {
+    $header = [];
+    $header['label'] = $this->t('Embed button');
+    $header['embed_type'] = $this->t('Embed type');
+    $header['icon'] = [
+      'data' => $this->t('Icon'),
+      'class' => [RESPONSIVE_PRIORITY_LOW],
+    ];
+    return $header + parent::buildHeader();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildRow(EntityInterface $entity) {
+    /** @var \Drupal\embed\EmbedButtonInterface $entity */
+    $row = [];
+    $row['label'] = $entity->label();
+    $row['embed_type'] = $entity->getTypeLabel();
+    if ($icon_url = $entity->getIconUrl()) {
+      $row['icon']['data'] = [
+        '#theme' => 'image',
+        '#uri' => $icon_url,
+        '#alt' => $this->t('Icon for the @label button.', ['@label' => $entity->label()]),
+      ];
+    }
+    else {
+      $row['icon'] = $this->t('None');
+    }
+
+    return $row + parent::buildRow($entity);
+  }
+
+}