1cb5ff0a542c9b8a20ea91f0e0bae80650a31100
[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  * @internal
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.
21  *
22  * @see \Drupal\Core\Layout\LayoutInterface
23  * @see \Drupal\Core\Layout\LayoutDefault
24  * @see \Drupal\Core\Layout\LayoutPluginManager
25  * @see plugin_api
26  *
27  * @Annotation
28  */
29 class Layout extends Plugin {
30
31   /**
32    * The plugin ID.
33    *
34    * @var string
35    */
36   public $id;
37
38   /**
39    * The human-readable name.
40    *
41    * @var string
42    *
43    * @ingroup plugin_translatable
44    */
45   public $label;
46
47   /**
48    * An optional description for advanced layouts.
49    *
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.
54    *
55    * @var string
56    *
57    * @ingroup plugin_translatable
58    */
59   public $description;
60
61   /**
62    * The human-readable category.
63    *
64    * @var string
65    *
66    * @see \Drupal\Component\Plugin\CategorizingPluginManagerInterface
67    *
68    * @ingroup plugin_translatable
69    */
70   public $category;
71
72   /**
73    * The template file to render this layout (relative to the 'path' given).
74    *
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
77    * need to do it.
78    *
79    * @var string optional
80    *
81    * @see hook_theme()
82    */
83   public $template;
84
85   /**
86    * The theme hook used to render this layout.
87    *
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.
91    *
92    * @var string optional
93    *
94    * @see hook_theme()
95    */
96   public $theme_hook = 'layout';
97
98   /**
99    * Path (relative to the module or theme) to resources like icon or template.
100    *
101    * @var string optional
102    */
103   public $path;
104
105   /**
106    * The asset library.
107    *
108    * @var string optional
109    */
110   public $library;
111
112   /**
113    * The path to the preview image (relative to the 'path' given).
114    *
115    * @var string optional
116    */
117   public $icon;
118
119   /**
120    * An associative array of regions in this layout.
121    *
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.
125    *
126    * Any remaining keys may have special meaning for the given layout plugin,
127    * but are undefined here.
128    *
129    * @var array
130    */
131   public $regions = [];
132
133   /**
134    * The default region.
135    *
136    * @var string
137    */
138   public $default_region;
139
140   /**
141    * The layout plugin class.
142    *
143    * This default value is used for plugins defined in layouts.yml that do not
144    * specify a class themselves.
145    *
146    * @var string
147    */
148   public $class = LayoutDefault::class;
149
150   /**
151    * {@inheritdoc}
152    */
153   public function get() {
154     return new LayoutDefinition($this->definition);
155   }
156
157 }