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 / 2 |
CRAP | |
0.00% |
0 / 1 |
||
| PageTitleSource | |
0.00% |
0 / 2 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
||
| getPropValue | |
0.00% |
0 / 1 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 1 |
2 | |||||
| getValue | |
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_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: 'page_title', |
| 20 | label: new TranslatableMarkup('[Page] Title'), |
| 21 | description: new TranslatableMarkup('The Drupal `Page title` block (page_title).'), |
| 22 | prop_types: ['string'], |
| 23 | tags: [], |
| 24 | context_requirements: ['page'], |
| 25 | context_definitions: [] |
| 26 | )] |
| 27 | class PageTitleSource extends SourcePluginBase { |
| 28 | |
| 29 | /** |
| 30 | * {@inheritdoc} |
| 31 | */ |
| 32 | public function getPropValue(): mixed { |
| 33 | return ''; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get the value from settings. |
| 38 | * |
| 39 | * @param \Drupal\ui_patterns\PropTypeInterface|null $prop_type |
| 40 | * The prop type. |
| 41 | */ |
| 42 | public function getValue(?PropTypeInterface $prop_type = NULL): mixed { |
| 43 | return $this->configuration['settings']; |
| 44 | } |
| 45 | |
| 46 | } |