Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
LocalActionsSource | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
getPropValue | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
settingsForm | |
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\Form\FormStateInterface; |
8 | use Drupal\Core\StringTranslation\TranslatableMarkup; |
9 | use Drupal\ui_patterns\Attribute\Source; |
10 | use Drupal\ui_patterns\SourcePluginBase; |
11 | |
12 | /** |
13 | * Plugin implementation of the source. |
14 | * |
15 | * The plugin_id is set manually for the BlockSource to process. |
16 | */ |
17 | #[Source( |
18 | id: 'local_actions', |
19 | label: new TranslatableMarkup('[Page] Local actions'), |
20 | description: new TranslatableMarkup('The Drupal admin actions `local actions` block (local_actions_block).'), |
21 | prop_types: ['slot'], |
22 | tags: [], |
23 | context_requirements: ['page'], |
24 | context_definitions: [] |
25 | )] |
26 | class LocalActionsSource extends SourcePluginBase { |
27 | |
28 | /** |
29 | * {@inheritdoc} |
30 | */ |
31 | public function getPropValue(): mixed { |
32 | $this->setSettings([ |
33 | 'plugin_id' => 'local_actions_block', |
34 | 'local_actions_block' => [ |
35 | 'id' => 'local_actions_block', |
36 | 'label' => 'Primary admin actions', |
37 | 'label_display' => '', |
38 | 'provider' => 'system', |
39 | ], |
40 | ]); |
41 | |
42 | $configuration = $this->getSetting('local_actions_block') ?? []; |
43 | /** @var \Drupal\Core\Block\BlockPluginInterface $block */ |
44 | $block = \Drupal::service('plugin.manager.block')->createInstance('local_actions_block', $configuration); |
45 | |
46 | return $block->build(); |
47 | } |
48 | |
49 | /** |
50 | * {@inheritdoc} |
51 | */ |
52 | public function settingsForm(array $form, FormStateInterface $form_state): array { |
53 | // Do not pick config from parent source as we force a block id. |
54 | return $form; |
55 | } |
56 | |
57 | } |