Layout.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. namespace Drupal\Core\Layout\Annotation;
  3. use Drupal\Component\Annotation\Plugin;
  4. use Drupal\Core\Layout\LayoutDefault;
  5. use Drupal\Core\Layout\LayoutDefinition;
  6. /**
  7. * Defines a Layout annotation object.
  8. *
  9. * Layouts are used to define a list of regions and then output render arrays
  10. * in each of the regions, usually using a template.
  11. *
  12. * Plugin namespace: Plugin\Layout
  13. *
  14. * @see \Drupal\Core\Layout\LayoutInterface
  15. * @see \Drupal\Core\Layout\LayoutDefault
  16. * @see \Drupal\Core\Layout\LayoutPluginManager
  17. * @see plugin_api
  18. *
  19. * @Annotation
  20. */
  21. class Layout extends Plugin {
  22. /**
  23. * The plugin ID.
  24. *
  25. * @var string
  26. */
  27. public $id;
  28. /**
  29. * The human-readable name.
  30. *
  31. * @var string
  32. *
  33. * @ingroup plugin_translatable
  34. */
  35. public $label;
  36. /**
  37. * An optional description for advanced layouts.
  38. *
  39. * Sometimes layouts are so complex that the name is insufficient to describe
  40. * a layout such that a visually impaired administrator could layout a page
  41. * for a non-visually impaired audience. If specified, it will provide a
  42. * description that is used for accessibility purposes.
  43. *
  44. * @var string
  45. *
  46. * @ingroup plugin_translatable
  47. */
  48. public $description;
  49. /**
  50. * The human-readable category.
  51. *
  52. * @var string
  53. *
  54. * @see \Drupal\Component\Plugin\CategorizingPluginManagerInterface
  55. *
  56. * @ingroup plugin_translatable
  57. */
  58. public $category;
  59. /**
  60. * The template file to render this layout (relative to the 'path' given).
  61. *
  62. * If specified, then the layout_discovery module will register the template
  63. * with hook_theme() and the module or theme registering this layout does not
  64. * need to do it.
  65. *
  66. * @var string optional
  67. *
  68. * @see hook_theme()
  69. */
  70. public $template;
  71. /**
  72. * The theme hook used to render this layout.
  73. *
  74. * If specified, it's assumed that the module or theme registering this layout
  75. * will also register the theme hook with hook_theme() itself. This is
  76. * mutually exclusive with 'template' - you can't specify both.
  77. *
  78. * @var string optional
  79. *
  80. * @see hook_theme()
  81. */
  82. public $theme_hook = 'layout';
  83. /**
  84. * Path (relative to the module or theme) to resources like icon or template.
  85. *
  86. * @var string optional
  87. */
  88. public $path;
  89. /**
  90. * The asset library.
  91. *
  92. * @var string optional
  93. */
  94. public $library;
  95. /**
  96. * The path to the preview image (relative to the 'path' given).
  97. *
  98. * @var string optional
  99. */
  100. public $icon;
  101. /**
  102. * The icon map.
  103. *
  104. * @var string[][] optional
  105. *
  106. * @see \Drupal\Core\Layout\Icon\IconBuilderInterface::build()
  107. */
  108. public $icon_map;
  109. /**
  110. * An associative array of regions in this layout.
  111. *
  112. * The key of the array is the machine name of the region, and the value is
  113. * an associative array with the following keys:
  114. * - label: (string) The human-readable name of the region.
  115. *
  116. * Any remaining keys may have special meaning for the given layout plugin,
  117. * but are undefined here.
  118. *
  119. * @var array
  120. */
  121. public $regions = [];
  122. /**
  123. * The default region.
  124. *
  125. * @var string
  126. */
  127. public $default_region;
  128. /**
  129. * The layout plugin class.
  130. *
  131. * This default value is used for plugins defined in layouts.yml that do not
  132. * specify a class themselves.
  133. *
  134. * @var string
  135. */
  136. public $class = LayoutDefault::class;
  137. /**
  138. * {@inheritdoc}
  139. */
  140. public function get() {
  141. return new LayoutDefinition($this->definition);
  142. }
  143. }