Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| MenuStyles | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| build | |
0.00% |
0 / 13 |
|
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 | * Adds copy/paste/merge/delete actions for the ui_styles third-party |
| 17 | * setting a node carries (@see StylesPanel), independent of copying the |
| 18 | * node itself. |
| 19 | */ |
| 20 | #[Island( |
| 21 | id: 'menu_styles', |
| 22 | label: new TranslatableMarkup('Styles menu'), |
| 23 | description: new TranslatableMarkup('Copy, paste, merge and delete styles.'), |
| 24 | type: IslandType::Menu, |
| 25 | modules: ['ui_styles'], |
| 26 | )] |
| 27 | class MenuStyles extends IslandPluginBase { |
| 28 | |
| 29 | /** |
| 30 | * {@inheritdoc} |
| 31 | */ |
| 32 | public function build(InstanceInterface $builder, array $data = [], array $options = []): array { |
| 33 | $builder_id = (string) $builder->id(); |
| 34 | |
| 35 | $copy = $this->buildMenuItem($this->t('Copy'), 'copy_styles'); |
| 36 | |
| 37 | $paste = $this->buildMenuItem($this->t('Paste'), 'paste_styles'); |
| 38 | $paste = $this->htmxEvents->onClickPasteStyles($paste, $builder_id); |
| 39 | |
| 40 | $merge = $this->buildMenuItem($this->t('Merge'), 'merge_styles'); |
| 41 | $merge = $this->htmxEvents->onClickPasteStyles($merge, $builder_id); |
| 42 | |
| 43 | $delete = $this->buildMenuItem($this->t('Delete'), 'delete_styles'); |
| 44 | $delete = $this->htmxEvents->onClickDeleteStyles($delete, $builder_id); |
| 45 | |
| 46 | $styles = $this->buildMenuItem($this->t('Styles'), '', submenu: [$copy, $paste, $merge, $delete]); |
| 47 | |
| 48 | return [ |
| 49 | $this->buildMenuDivider(), |
| 50 | $styles, |
| 51 | ]; |
| 52 | } |
| 53 | |
| 54 | } |
Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not
necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once.
Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 32 | public function build(InstanceInterface $builder, array $data = [], array $options = []): array { |
| 33 | $builder_id = (string) $builder->id(); |
| 34 | |
| 35 | $copy = $this->buildMenuItem($this->t('Copy'), 'copy_styles'); |
| 36 | |
| 37 | $paste = $this->buildMenuItem($this->t('Paste'), 'paste_styles'); |
| 38 | $paste = $this->htmxEvents->onClickPasteStyles($paste, $builder_id); |
| 39 | |
| 40 | $merge = $this->buildMenuItem($this->t('Merge'), 'merge_styles'); |
| 41 | $merge = $this->htmxEvents->onClickPasteStyles($merge, $builder_id); |
| 42 | |
| 43 | $delete = $this->buildMenuItem($this->t('Delete'), 'delete_styles'); |
| 44 | $delete = $this->htmxEvents->onClickDeleteStyles($delete, $builder_id); |
| 45 | |
| 46 | $styles = $this->buildMenuItem($this->t('Styles'), '', submenu: [$copy, $paste, $merge, $delete]); |
| 47 | |
| 48 | return [ |
| 49 | $this->buildMenuDivider(), |
| 50 | $styles, |
| 51 | ]; |
| 52 | } |