EmbedButtonListBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildHeader() 0 10 1
A buildRow() 0 18 2
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
}
50