Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / Controller / ParagraphsTypeListBuilder.php
1 <?php
2
3 namespace Drupal\paragraphs\Controller;
4
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
7
8 /**
9  * Provides a listing of ParagraphsType.
10  */
11 class ParagraphsTypeListBuilder extends ConfigEntityListBuilder {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function buildHeader() {
17     $header['icon_file'] = [
18       'data' => $this->t('Icon'),
19     ];
20     $header['label'] = $this->t('Label');
21     $header['id'] = $this->t('Machine name');
22     $header['description'] = $this->t('Description');
23
24     return $header + parent::buildHeader();
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function buildRow(EntityInterface $entity) {
31     $row['icon_file'] = [];
32     if ($icon_url = $entity->getIconUrl()) {
33       $row['icon_file']['class'][] = 'paragraphs-type-icon';
34       $row['icon_file']['data'] = [
35         '#theme' => 'image',
36         '#uri' => $icon_url,
37         '#width' => 32,
38         '#height' => 32,
39       ];
40     }
41     $row['label'] = $entity->label();
42     $row['id'] = $entity->id();
43     $row['description']['data'] = ['#markup' => $entity->getDescription()];
44     // You probably want a few more properties here...
45     return $row + parent::buildRow($entity);
46   }
47
48   /**
49    * {@inheritdoc}
50    */
51   public function getDefaultOperations(EntityInterface $entity) {
52     /** @var \Drupal\field\FieldConfigInterface $entity */
53     $operations = parent::getDefaultOperations($entity);
54
55     if (isset($operations['edit'])) {
56       $operations['edit']['weight'] = 30;
57     }
58
59     return $operations;
60   }
61
62   /**
63    * {@inheritdoc}
64    */
65   public function render() {
66     $build = parent::render();
67     $build['#attached']['library'][] = 'paragraphs/drupal.paragraphs.list_builder';
68     return $build;
69   }
70
71 }