Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 20 |
|
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| IslandType | |
0.00% |
0 / 15 |
|
0.00% |
0 / 20 |
|
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
132 | |
0.00% |
0 / 1 |
| description | |
0.00% |
0 / 6 |
|
0.00% |
0 / 13 |
|
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
56 | |||
| regions | |
0.00% |
0 / 9 |
|
0.00% |
0 / 7 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\display_builder; |
| 6 | |
| 7 | use Drupal\Core\StringTranslation\TranslatableMarkup; |
| 8 | |
| 9 | /** |
| 10 | * List the island types for display builder. |
| 11 | */ |
| 12 | enum IslandType: string { |
| 13 | |
| 14 | // Islands acting as part of view island. |
| 15 | case Library = 'library'; |
| 16 | case Contextual = 'contextual'; |
| 17 | case View = 'view'; |
| 18 | case Button = 'button'; |
| 19 | case Menu = 'menu'; |
| 20 | |
| 21 | /** |
| 22 | * Get the string description for this enum. |
| 23 | * |
| 24 | * @param string $type |
| 25 | * The enum string name. |
| 26 | * |
| 27 | * @return \Drupal\Core\StringTranslation\TranslatableMarkup |
| 28 | * The enum string description. |
| 29 | */ |
| 30 | public static function description(string $type): TranslatableMarkup { |
| 31 | return match ($type) { |
| 32 | self::View->value => new TranslatableMarkup('Panels shown as a main area tab or as a sidebar.'), |
| 33 | self::Library->value => new TranslatableMarkup('Panels available as tab in the Library panel.'), |
| 34 | self::Button->value => new TranslatableMarkup('Toolbar buttons allowing direct actions in the builder.'), |
| 35 | self::Contextual->value => new TranslatableMarkup('Panels visible only when the a source is selected.'), |
| 36 | self::Menu->value => new TranslatableMarkup('Items available in the contextual menu.'), |
| 37 | default => new TranslatableMarkup('Unknown island type.'), |
| 38 | }; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get the available regions by type. |
| 43 | * |
| 44 | * @return array |
| 45 | * The type regions as key => description. |
| 46 | */ |
| 47 | public static function regions(string $type): array { |
| 48 | return match ($type) { |
| 49 | self::View->value => [ |
| 50 | 'sidebar' => new TranslatableMarkup('Sidebar'), |
| 51 | 'main' => new TranslatableMarkup('Main area (Tabs)'), |
| 52 | ], |
| 53 | self::Button->value => [ |
| 54 | 'start' => new TranslatableMarkup('Start'), |
| 55 | 'end' => new TranslatableMarkup('End'), |
| 56 | ], |
| 57 | default => [], |
| 58 | }; |
| 59 | } |
| 60 | |
| 61 | } |