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