Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 2
IslandType
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
56
0.00% covered (danger)
0.00%
0 / 1
 description
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
56
IslandTypeViewDisplay
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 regions
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder;
6
7use Drupal\Core\StringTranslation\TranslatableMarkup;
8
9/**
10 * List the island types for display builder.
11 */
12enum 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('Islands shown as a main area tabs or as an offcanvas sidebar.'),
33      self::Library->value => new TranslatableMarkup('Islands available as tab in the Library island.'),
34      self::Button->value => new TranslatableMarkup('Toolbar buttons are displayed on the end of the toolbar and allow direct actions in the builder.'),
35      self::Contextual->value => new TranslatableMarkup('Islands visible only when the related instance is active and selected. They allow actions on an element selected in the builder.'),
36      self::Menu->value => new TranslatableMarkup('Islands that act on the contextual menu, providing specific entries.'),
37      default => new TranslatableMarkup('Unknown island type.'),
38    };
39  }
40
41}
42
43/**
44 * List the island sub types for IslandType::View.
45 */
46enum IslandTypeViewDisplay: string {
47
48  case Sidebar = 'sidebar';
49  case Main = 'main';
50
51  /**
52   * Get the type list regions.
53   *
54   * @return array
55   *   The type list regions as key => description.
56   */
57  public static function regions(): array {
58    return [
59      IslandTypeViewDisplay::Sidebar->value => new TranslatableMarkup('Sidebar (OffCanvas)'),
60      IslandTypeViewDisplay::Main->value => new TranslatableMarkup('Main area (Tabs in the toolbar)'),
61    ];
62  }
63
64}