Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 10 |
|
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| UiPatternsHooks | |
0.00% |
0 / 13 |
|
0.00% |
0 / 10 |
|
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sourceValueAlter | |
0.00% |
0 / 6 |
|
0.00% |
0 / 8 |
|
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
30 | |||
| schemaInfoAlter | |
0.00% |
0 / 6 |
|
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\Hook; |
| 6 | |
| 7 | use Drupal\Core\Hook\Attribute\Hook; |
| 8 | use Drupal\display_builder\IslandPluginManagerInterface; |
| 9 | use Drupal\display_builder\RenderableAltererInterface; |
| 10 | use Drupal\ui_patterns\SourceInterface; |
| 11 | |
| 12 | /** |
| 13 | * Hook implementations for display_builder. |
| 14 | */ |
| 15 | class UiPatternsHooks { |
| 16 | |
| 17 | public function __construct( |
| 18 | protected IslandPluginManagerInterface $islandManager, |
| 19 | ) {} |
| 20 | |
| 21 | /** |
| 22 | * Alters the renderable array for a component that has been built. |
| 23 | * |
| 24 | * @param mixed &$build |
| 25 | * The renderable array of the component. |
| 26 | * @param \Drupal\ui_patterns\SourceInterface $source |
| 27 | * The data array containing information about the component. |
| 28 | * @param array $source_configuration |
| 29 | * The full raw configuration used to build the source. |
| 30 | */ |
| 31 | #[Hook('ui_patterns_source_value_alter')] |
| 32 | public function sourceValueAlter(mixed &$build, SourceInterface $source, array &$source_configuration): void { |
| 33 | if (!isset($source_configuration['_third_party_settings'])) { |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 41 | $build = $island->alterElement($build, $settings); |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Add third-party-settings to UI Patterns slot source schema. |
| 48 | * |
| 49 | * Can be removed once |
| 50 | * https://www.drupal.org/project/ui_patterns/issues/3540614 is merged. |
| 51 | * |
| 52 | * @param array $definitions |
| 53 | * Associative array of configuration type definitions keyed by schema type |
| 54 | * names. The elements are themselves array with information about the type. |
| 55 | */ |
| 56 | #[Hook('config_schema_info_alter')] |
| 57 | public function schemaInfoAlter(array &$definitions): void { |
| 58 | $definitions['ui_patterns_slot_source']['mapping']['_third_party_settings'] = [ |
| 59 | 'type' => 'sequence', |
| 60 | 'sequence' => [ |
| 61 | 'type' => 'ui_patterns_slot_source.third_party_setting.[%key]', |
| 62 | ], |
| 63 | ]; |
| 64 | } |
| 65 | |
| 66 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 17 | public function __construct( |
| 18 | protected IslandPluginManagerInterface $islandManager, |
| 19 | ) {} |
| 57 | public function schemaInfoAlter(array &$definitions): void { |
| 58 | $definitions['ui_patterns_slot_source']['mapping']['_third_party_settings'] = [ |
| 59 | 'type' => 'sequence', |
| 60 | 'sequence' => [ |
| 61 | 'type' => 'ui_patterns_slot_source.third_party_setting.[%key]', |
| 62 | ], |
| 63 | ]; |
| 64 | } |
| 32 | public function sourceValueAlter(mixed &$build, SourceInterface $source, array &$source_configuration): void { |
| 33 | if (!isset($source_configuration['_third_party_settings'])) { |
| 34 | return; |
| 32 | public function sourceValueAlter(mixed &$build, SourceInterface $source, array &$source_configuration): void { |
| 33 | if (!isset($source_configuration['_third_party_settings'])) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 41 | $build = $island->alterElement($build, $settings); |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 41 | $build = $island->alterElement($build, $settings); |
| 42 | } |
| 43 | } |
| 44 | } |
| 32 | public function sourceValueAlter(mixed &$build, SourceInterface $source, array &$source_configuration): void { |
| 33 | if (!isset($source_configuration['_third_party_settings'])) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 41 | $build = $island->alterElement($build, $settings); |
| 42 | } |
| 43 | } |
| 44 | } |
| 32 | public function sourceValueAlter(mixed &$build, SourceInterface $source, array &$source_configuration): void { |
| 33 | if (!isset($source_configuration['_third_party_settings'])) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 41 | $build = $island->alterElement($build, $settings); |
| 42 | } |
| 43 | } |
| 44 | } |
| 32 | public function sourceValueAlter(mixed &$build, SourceInterface $source, array &$source_configuration): void { |
| 33 | if (!isset($source_configuration['_third_party_settings'])) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 41 | $build = $island->alterElement($build, $settings); |
| 42 | } |
| 43 | } |
| 44 | } |
| 32 | public function sourceValueAlter(mixed &$build, SourceInterface $source, array &$source_configuration): void { |
| 33 | if (!isset($source_configuration['_third_party_settings'])) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 37 | foreach ($source_configuration['_third_party_settings'] as $island_id => $settings) { |
| 38 | $island = $this->islandManager->createInstance($island_id); |
| 39 | |
| 40 | if ($build && $island instanceof RenderableAltererInterface) { |
| 41 | $build = $island->alterElement($build, $settings); |
| 42 | } |
| 43 | } |
| 44 | } |