Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
PatternPresetListBuilder | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
buildHeader | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
buildRow | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
render | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Drupal\display_builder_ui; |
6 | |
7 | use Drupal\Core\Config\Entity\ConfigEntityListBuilder; |
8 | use Drupal\Core\Entity\EntityInterface; |
9 | |
10 | /** |
11 | * Provides a listing of Pattern presets. |
12 | */ |
13 | final class PatternPresetListBuilder extends ConfigEntityListBuilder { |
14 | |
15 | /** |
16 | * {@inheritdoc} |
17 | */ |
18 | public function buildHeader(): array { |
19 | $header = []; |
20 | $header['label'] = $this->t('Label'); |
21 | $header['description'] = $this->t('Description'); |
22 | $header['themes'] = $this->t('Themes'); |
23 | |
24 | return $header + parent::buildHeader(); |
25 | } |
26 | |
27 | /** |
28 | * {@inheritdoc} |
29 | */ |
30 | public function buildRow(EntityInterface $entity): array { |
31 | /** @var \Drupal\display_builder\PatternPresetInterface $entity */ |
32 | $row = []; |
33 | $row['label'] = $entity->label(); |
34 | $row['description'] = $entity->get('description') ?: $entity->getSummary(); |
35 | $row['themes'] = \implode(', ', $entity->getDependencies()['theme'] ?? []); |
36 | |
37 | return $row + parent::buildRow($entity); |
38 | } |
39 | |
40 | /** |
41 | * {@inheritdoc} |
42 | */ |
43 | public function render(): array { |
44 | $build = parent::render(); |
45 | $build['notice'] = [ |
46 | '#markup' => $this->t('A Pattern preset is a reusable arrangement of components.<br>A preset can be created manually or from a Display builder directly.'), |
47 | '#prefix' => '<div class="description">', |
48 | '#suffix' => '</div>', |
49 | '#weight' => -100, |
50 | ]; |
51 | |
52 | return $build; |
53 | } |
54 | |
55 | } |