Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
MainPageContentSource | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
getPropValue | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
getValue | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Drupal\display_builder_page_layout\Plugin\UiPatterns\Source; |
6 | |
7 | use Drupal\Core\StringTranslation\TranslatableMarkup; |
8 | use Drupal\ui_patterns\Attribute\Source; |
9 | use Drupal\ui_patterns\PropTypeInterface; |
10 | use Drupal\ui_patterns\SourcePluginBase; |
11 | |
12 | /** |
13 | * Plugin implementation of the source. |
14 | * |
15 | * Slot is explicitly added to prop_types to allow getPropValue |
16 | * to return a renderable array in case of slot prop type. |
17 | */ |
18 | #[Source( |
19 | id: 'main_page_content', |
20 | label: new TranslatableMarkup('[Page] Main content'), |
21 | description: new TranslatableMarkup('The Drupal `Main page content` block (system_main_block).'), |
22 | prop_types: ['slot'], |
23 | tags: [], |
24 | context_requirements: ['page'], |
25 | context_definitions: [] |
26 | )] |
27 | class MainPageContentSource extends SourcePluginBase { |
28 | |
29 | /** |
30 | * {@inheritdoc} |
31 | */ |
32 | public function getPropValue(): mixed { |
33 | $isSlot = ($this->propDefinition['ui_patterns']['type_definition']->getPluginId() === 'slot'); |
34 | |
35 | return $isSlot ? [] : ''; |
36 | } |
37 | |
38 | /** |
39 | * Get the value from settings. |
40 | * |
41 | * @param \Drupal\ui_patterns\PropTypeInterface|null $prop_type |
42 | * The prop type. |
43 | */ |
44 | public function getValue(?PropTypeInterface $prop_type = NULL): mixed { |
45 | return $this->configuration['settings']; |
46 | } |
47 | |
48 | } |