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
17 * @see \Drupal\Core\Layout\LayoutInterface
18 * @see \Drupal\Core\Layout\LayoutDefault
19 * @see \Drupal\Core\Layout\LayoutPluginManager
24 class Layout extends Plugin {
34 * The human-readable name.
38 * @ingroup plugin_translatable
43 * An optional description for advanced layouts.
45 * Sometimes layouts are so complex that the name is insufficient to describe
46 * a layout such that a visually impaired administrator could layout a page
47 * for a non-visually impaired audience. If specified, it will provide a
48 * description that is used for accessibility purposes.
52 * @ingroup plugin_translatable
57 * The human-readable category.
61 * @see \Drupal\Component\Plugin\CategorizingPluginManagerInterface
63 * @ingroup plugin_translatable
68 * The template file to render this layout (relative to the 'path' given).
70 * If specified, then the layout_discovery module will register the template
71 * with hook_theme() and the module or theme registering this layout does not
74 * @var string optional
81 * The theme hook used to render this layout.
83 * If specified, it's assumed that the module or theme registering this layout
84 * will also register the theme hook with hook_theme() itself. This is
85 * mutually exclusive with 'template' - you can't specify both.
87 * @var string optional
91 public $theme_hook = 'layout';
94 * Path (relative to the module or theme) to resources like icon or template.
96 * @var string optional
103 * @var string optional
108 * The path to the preview image (relative to the 'path' given).
110 * @var string optional
117 * @var string[][] optional
119 * @see \Drupal\Core\Layout\Icon\IconBuilderInterface::build()
124 * An associative array of regions in this layout.
126 * The key of the array is the machine name of the region, and the value is
127 * an associative array with the following keys:
128 * - label: (string) The human-readable name of the region.
130 * Any remaining keys may have special meaning for the given layout plugin,
131 * but are undefined here.
135 public $regions = [];
138 * The default region.
142 public $default_region;
145 * The layout plugin class.
147 * This default value is used for plugins defined in layouts.yml that do not
148 * specify a class themselves.
152 public $class = LayoutDefault::class;
157 public function get() {
158 return new LayoutDefinition($this->definition);