3 namespace Drupal\Core\Layout\Annotation;
5 use Drupal\Component\Annotation\Plugin;
6 use Drupal\Core\Layout\LayoutDefault;
7 use Drupal\Core\Layout\LayoutDefinition;
10 * Defines a Layout annotation object.
12 * Layouts are used to define a list of regions and then output render arrays
13 * in each of the regions, usually using a template.
15 * Plugin namespace: Plugin\Layout
18 * The layout system is currently experimental and should only be leveraged by
19 * experimental modules and development releases of contributed modules.
20 * See https://www.drupal.org/core/experimental for more information.
22 * @see \Drupal\Core\Layout\LayoutInterface
23 * @see \Drupal\Core\Layout\LayoutDefault
24 * @see \Drupal\Core\Layout\LayoutPluginManager
29 class Layout extends Plugin {
39 * The human-readable name.
43 * @ingroup plugin_translatable
48 * An optional description for advanced layouts.
50 * Sometimes layouts are so complex that the name is insufficient to describe
51 * a layout such that a visually impaired administrator could layout a page
52 * for a non-visually impaired audience. If specified, it will provide a
53 * description that is used for accessibility purposes.
57 * @ingroup plugin_translatable
62 * The human-readable category.
66 * @see \Drupal\Component\Plugin\CategorizingPluginManagerInterface
68 * @ingroup plugin_translatable
73 * The template file to render this layout (relative to the 'path' given).
75 * If specified, then the layout_discovery module will register the template
76 * with hook_theme() and the module or theme registering this layout does not
79 * @var string optional
86 * The theme hook used to render this layout.
88 * If specified, it's assumed that the module or theme registering this layout
89 * will also register the theme hook with hook_theme() itself. This is
90 * mutually exclusive with 'template' - you can't specify both.
92 * @var string optional
96 public $theme_hook = 'layout';
99 * Path (relative to the module or theme) to resources like icon or template.
101 * @var string optional
108 * @var string optional
113 * The path to the preview image (relative to the 'path' given).
115 * @var string optional
120 * An associative array of regions in this layout.
122 * The key of the array is the machine name of the region, and the value is
123 * an associative array with the following keys:
124 * - label: (string) The human-readable name of the region.
126 * Any remaining keys may have special meaning for the given layout plugin,
127 * but are undefined here.
131 public $regions = [];
134 * The default region.
138 public $default_region;
141 * The layout plugin class.
143 * This default value is used for plugins defined in layouts.yml that do not
144 * specify a class themselves.
148 public $class = LayoutDefault::class;
153 public function get() {
154 return new LayoutDefinition($this->definition);