eae930cf4eb1bfe338c6830722e0ed309083bb04
[yaffs-website] / web / core / lib / Drupal / Core / Layout / Annotation / Layout.php
1 <?php
2
3 namespace Drupal\Core\Layout\Annotation;
4
5 use Drupal\Component\Annotation\Plugin;
6 use Drupal\Core\Layout\LayoutDefault;
7 use Drupal\Core\Layout\LayoutDefinition;
8
9 /**
10  * Defines a Layout annotation object.
11  *
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.
14  *
15  * Plugin namespace: Plugin\Layout
16  *
17  * @see \Drupal\Core\Layout\LayoutInterface
18  * @see \Drupal\Core\Layout\LayoutDefault
19  * @see \Drupal\Core\Layout\LayoutPluginManager
20  * @see plugin_api
21  *
22  * @Annotation
23  */
24 class Layout extends Plugin {
25
26   /**
27    * The plugin ID.
28    *
29    * @var string
30    */
31   public $id;
32
33   /**
34    * The human-readable name.
35    *
36    * @var string
37    *
38    * @ingroup plugin_translatable
39    */
40   public $label;
41
42   /**
43    * An optional description for advanced layouts.
44    *
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.
49    *
50    * @var string
51    *
52    * @ingroup plugin_translatable
53    */
54   public $description;
55
56   /**
57    * The human-readable category.
58    *
59    * @var string
60    *
61    * @see \Drupal\Component\Plugin\CategorizingPluginManagerInterface
62    *
63    * @ingroup plugin_translatable
64    */
65   public $category;
66
67   /**
68    * The template file to render this layout (relative to the 'path' given).
69    *
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
72    * need to do it.
73    *
74    * @var string optional
75    *
76    * @see hook_theme()
77    */
78   public $template;
79
80   /**
81    * The theme hook used to render this layout.
82    *
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.
86    *
87    * @var string optional
88    *
89    * @see hook_theme()
90    */
91   public $theme_hook = 'layout';
92
93   /**
94    * Path (relative to the module or theme) to resources like icon or template.
95    *
96    * @var string optional
97    */
98   public $path;
99
100   /**
101    * The asset library.
102    *
103    * @var string optional
104    */
105   public $library;
106
107   /**
108    * The path to the preview image (relative to the 'path' given).
109    *
110    * @var string optional
111    */
112   public $icon;
113
114   /**
115    * The icon map.
116    *
117    * @var string[][] optional
118    *
119    * @see \Drupal\Core\Layout\Icon\IconBuilderInterface::build()
120    */
121   public $icon_map;
122
123   /**
124    * An associative array of regions in this layout.
125    *
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.
129    *
130    * Any remaining keys may have special meaning for the given layout plugin,
131    * but are undefined here.
132    *
133    * @var array
134    */
135   public $regions = [];
136
137   /**
138    * The default region.
139    *
140    * @var string
141    */
142   public $default_region;
143
144   /**
145    * The layout plugin class.
146    *
147    * This default value is used for plugins defined in layouts.yml that do not
148    * specify a class themselves.
149    *
150    * @var string
151    */
152   public $class = LayoutDefault::class;
153
154   /**
155    * {@inheritdoc}
156    */
157   public function get() {
158     return new LayoutDefinition($this->definition);
159   }
160
161 }