Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 10 |
|
0.00% |
0 / 10 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
| DisplayBuilderEvent | |
0.00% |
0 / 10 |
|
0.00% |
0 / 10 |
|
0.00% |
0 / 10 |
|
0.00% |
0 / 10 |
110 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| appendResult | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getInstance | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getNodeId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getIslandConfiguration | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getEnabledIslands | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getParentId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getCurrentIslandId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getResult | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\display_builder\Event; |
| 6 | |
| 7 | use Drupal\Component\EventDispatcher\Event; |
| 8 | use Drupal\display_builder\InstanceInterface; |
| 9 | |
| 10 | /** |
| 11 | * Event fired when display builder is used. |
| 12 | */ |
| 13 | final class DisplayBuilderEvent extends Event { |
| 14 | |
| 15 | /** |
| 16 | * The result for this event. |
| 17 | * |
| 18 | * A render array. |
| 19 | */ |
| 20 | private array $result = []; |
| 21 | |
| 22 | /** |
| 23 | * Constructs a DisplayBuilderEvent object. |
| 24 | * |
| 25 | * @param \Drupal\display_builder\InstanceInterface $instance |
| 26 | * The display builder instance. |
| 27 | * @param array|null $data |
| 28 | * The data associated with this event. |
| 29 | * @param string|null $node_id |
| 30 | * The tree node ID. |
| 31 | * @param string|null $parent_id |
| 32 | * The parent node ID. |
| 33 | * @param string|null $current_island_id |
| 34 | * Optional current island ID which trigger action. |
| 35 | */ |
| 36 | public function __construct( |
| 37 | private InstanceInterface $instance, |
| 38 | private ?array $data = NULL, |
| 39 | private ?string $node_id = NULL, |
| 40 | private ?string $parent_id = NULL, |
| 41 | private ?string $current_island_id = NULL, |
| 42 | ) {} |
| 43 | |
| 44 | /** |
| 45 | * Append a result for this event. |
| 46 | * |
| 47 | * @param string $islandId |
| 48 | * The island ID. |
| 49 | * @param array $result |
| 50 | * The result array to append. |
| 51 | */ |
| 52 | public function appendResult(string $islandId, array $result): void { |
| 53 | $this->result[$islandId] = $result; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Gets the display builder instance. |
| 58 | * |
| 59 | * @return \Drupal\display_builder\InstanceInterface |
| 60 | * The display builder instance. |
| 61 | */ |
| 62 | public function getInstance(): InstanceInterface { |
| 63 | return $this->instance; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Gets the data associated with this event. |
| 68 | * |
| 69 | * @return array|null |
| 70 | * The event data. |
| 71 | */ |
| 72 | public function getData(): ?array { |
| 73 | return $this->data; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Gets the tree node ID. |
| 78 | * |
| 79 | * @return string |
| 80 | * The tree node ID. |
| 81 | */ |
| 82 | public function getNodeId(): ?string { |
| 83 | return $this->node_id; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Gets the enabled islands. |
| 88 | * |
| 89 | * @return array |
| 90 | * The enabled islands. |
| 91 | */ |
| 92 | public function getIslandConfiguration(): array { |
| 93 | return $this->instance->getProfile()->getIslandConfigurations(); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Gets the enabled islands. |
| 98 | * |
| 99 | * @return array |
| 100 | * The enabled islands. |
| 101 | */ |
| 102 | public function getEnabledIslands(): array { |
| 103 | return $this->instance->getProfile()->getEnabledIslands(); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Gets the parent node ID. |
| 108 | * |
| 109 | * @return string |
| 110 | * The parent node ID. |
| 111 | */ |
| 112 | public function getParentId(): ?string { |
| 113 | return $this->parent_id; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Gets the current island ID. |
| 118 | * |
| 119 | * @return string |
| 120 | * The current island ID which trigger action. |
| 121 | */ |
| 122 | public function getCurrentIslandId(): ?string { |
| 123 | return $this->current_island_id; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Gets the result for this event. |
| 128 | * |
| 129 | * @return array |
| 130 | * The result array, or empty array if not set. |
| 131 | */ |
| 132 | public function getResult(): array { |
| 133 | return $this->result; |
| 134 | } |
| 135 | |
| 136 | } |