Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
LocalTasksSource
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 getPropValue
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
2
 settingsForm
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder_page_layout\Plugin\UiPatterns\Source;
6
7use Drupal\Core\Form\FormStateInterface;
8use Drupal\Core\StringTranslation\TranslatableMarkup;
9use Drupal\ui_patterns\Attribute\Source;
10use 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_tasks',
19  label: new TranslatableMarkup('[Page] Local tasks'),
20  description: new TranslatableMarkup('The Drupal tabs `local tasks` block (local_tasks_block).'),
21  prop_types: ['slot'],
22  tags: [],
23  context_requirements: ['page'],
24  context_definitions: []
25)]
26class LocalTasksSource extends SourcePluginBase {
27
28  /**
29   * {@inheritdoc}
30   */
31  public function getPropValue(): mixed {
32    $this->setSettings([
33      'plugin_id' => 'local_tasks_block',
34      'local_tasks_block' => [
35        'id' => 'local_tasks_block',
36        'label' => 'Tabs',
37        'label_display' => '',
38        'provider' => 'system',
39        'primary' => TRUE,
40        'secondary' => TRUE,
41      ],
42    ]);
43
44    $configuration = $this->getSetting('local_tasks_block') ?? [];
45    /** @var \Drupal\Core\Block\BlockPluginInterface $block */
46    $block = \Drupal::service('plugin.manager.block')->createInstance('local_tasks_block', $configuration);
47
48    return $block->build();
49  }
50
51  /**
52   * {@inheritdoc}
53   */
54  public function settingsForm(array $form, FormStateInterface $form_state): array {
55    // Do not pick config from parent source as we force a block id.
56    return $form;
57  }
58
59}