Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| MenuDelete | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| build | |
0.00% |
0 / 10 |
|
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\Plugin\display_builder\Island; |
| 6 | |
| 7 | use Drupal\Core\StringTranslation\TranslatableMarkup; |
| 8 | use Drupal\display_builder\Attribute\Island; |
| 9 | use Drupal\display_builder\InstanceInterface; |
| 10 | use Drupal\display_builder\Island\IslandPluginBase; |
| 11 | use Drupal\display_builder\Island\IslandType; |
| 12 | |
| 13 | /** |
| 14 | * Menu island plugin implementation. |
| 15 | */ |
| 16 | #[Island( |
| 17 | id: 'menu_delete', |
| 18 | enabled_by_default: TRUE, |
| 19 | label: new TranslatableMarkup('Delete'), |
| 20 | description: new TranslatableMarkup('Remove a component or block.'), |
| 21 | type: IslandType::Menu, |
| 22 | )] |
| 23 | class MenuDelete extends IslandPluginBase { |
| 24 | |
| 25 | /** |
| 26 | * {@inheritdoc} |
| 27 | */ |
| 28 | public function build(InstanceInterface $builder, array $data = [], array $options = []): array { |
| 29 | $builder_id = (string) $builder->id(); |
| 30 | |
| 31 | $remove = $this->buildMenuItem($this->t('Remove'), 'remove'); |
| 32 | // Also reachable with the Delete key, without opening the menu, acting on |
| 33 | // whichever node is currently selected. |
| 34 | // @see components/display_builder/js/keyboard.js |
| 35 | $remove['#attributes']['data-keyboard-key'] = 'Delete'; |
| 36 | $remove['#attributes']['data-keyboard-help'] = (string) $this->t('Remove the selected element'); |
| 37 | $remove['#attributes']['aria-keyshortcuts'] = 'Delete'; |
| 38 | $remove = $this->htmxEvents->onClickDelete($remove, $builder_id); |
| 39 | |
| 40 | return [ |
| 41 | $this->buildMenuDivider(), |
| 42 | $remove, |
| 43 | ]; |
| 44 | } |
| 45 | |
| 46 | } |