LayoutInterface.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View;
  7. /**
  8. * Interface LayoutInterface
  9. * @api
  10. * @since 100.0.2
  11. */
  12. interface LayoutInterface
  13. {
  14. /**
  15. * Retrieve the layout processor
  16. *
  17. * @return Layout\ProcessorInterface
  18. */
  19. public function getUpdate();
  20. /**
  21. * Layout xml generation
  22. *
  23. * @return LayoutInterface
  24. */
  25. public function generateXml();
  26. /**
  27. * Create structure of elements from the loaded XML configuration
  28. *
  29. * @return void
  30. */
  31. public function generateElements();
  32. /**
  33. * Find an element in layout, render it and return string with its output
  34. *
  35. * @param string $name
  36. * @param bool $useCache
  37. * @return string
  38. */
  39. public function renderElement($name, $useCache = true);
  40. /**
  41. * Add an element to output
  42. *
  43. * @param string $name
  44. * @return LayoutInterface
  45. */
  46. public function addOutputElement($name);
  47. /**
  48. * Get all blocks marked for output
  49. *
  50. * @return string
  51. */
  52. public function getOutput();
  53. /**
  54. * Check if element exists in layout structure
  55. *
  56. * @param string $name
  57. * @return bool
  58. */
  59. public function hasElement($name);
  60. /**
  61. * Remove block from registry
  62. *
  63. * @param string $name
  64. * @return LayoutInterface
  65. */
  66. public function unsetElement($name);
  67. /**
  68. * Retrieve all blocks from registry as array
  69. *
  70. * @return array
  71. */
  72. public function getAllBlocks();
  73. /**
  74. * Get block object by name
  75. *
  76. * @param string $name
  77. * @return Element\BlockInterface|bool
  78. */
  79. public function getBlock($name);
  80. /**
  81. * Get child block if exists
  82. *
  83. * @param string $parentName
  84. * @param string $alias
  85. * @return null
  86. */
  87. public function getChildBlock($parentName, $alias);
  88. /**
  89. * Set child element into layout structure
  90. *
  91. * @param string $parentName
  92. * @param string $elementName
  93. * @param string $alias
  94. * @return LayoutInterface
  95. */
  96. public function setChild($parentName, $elementName, $alias);
  97. /**
  98. * Reorder a child of a specified element
  99. *
  100. * If $offsetOrSibling is null, it will put the element to the end
  101. * If $offsetOrSibling is numeric (integer) value, it will put the element after/before specified position
  102. * Otherwise -- after/before specified sibling
  103. *
  104. * @param string $parentName
  105. * @param string $childName
  106. * @param string|int|null $offsetOrSibling
  107. * @param bool $after
  108. * @return void
  109. */
  110. public function reorderChild($parentName, $childName, $offsetOrSibling, $after = true);
  111. /**
  112. * Remove child element from parent
  113. *
  114. * @param string $parentName
  115. * @param string $alias
  116. * @return LayoutInterface
  117. */
  118. public function unsetChild($parentName, $alias);
  119. /**
  120. * Get list of child names
  121. *
  122. * @param string $parentName
  123. * @return array
  124. */
  125. public function getChildNames($parentName);
  126. /**
  127. * Get list of child blocks
  128. *
  129. * Returns associative array of <alias> => <block instance>
  130. *
  131. * @param string $parentName
  132. * @return array
  133. */
  134. public function getChildBlocks($parentName);
  135. /**
  136. * Get child name by alias
  137. *
  138. * @param string $parentName
  139. * @param string $alias
  140. * @return bool|string
  141. */
  142. public function getChildName($parentName, $alias);
  143. /**
  144. * Add element to parent group
  145. *
  146. * @param string $blockName
  147. * @param string $parentGroupName
  148. * @return bool
  149. */
  150. public function addToParentGroup($blockName, $parentGroupName);
  151. /**
  152. * Get element names for specified group
  153. *
  154. * @param string $blockName
  155. * @param string $groupName
  156. * @return array
  157. */
  158. public function getGroupChildNames($blockName, $groupName);
  159. /**
  160. * Gets parent name of an element with specified name
  161. *
  162. * @param string $childName
  163. * @return bool|string
  164. */
  165. public function getParentName($childName);
  166. /**
  167. * Block Factory
  168. *
  169. * @param string $type
  170. * @param string $name
  171. * @param array $arguments
  172. * @return Element\BlockInterface
  173. */
  174. public function createBlock($type, $name = '', array $arguments = []);
  175. /**
  176. * Add a block to registry, create new object if needed
  177. *
  178. * @param string|\Magento\Framework\View\Element\AbstractBlock $block
  179. * @param string $name
  180. * @param string $parent
  181. * @param string $alias
  182. * @return Element\BlockInterface
  183. */
  184. public function addBlock($block, $name = '', $parent = '', $alias = '');
  185. /**
  186. * Insert container into layout structure
  187. *
  188. * @param string $name
  189. * @param string $label
  190. * @param array $options
  191. * @param string $parent
  192. * @param string $alias
  193. * @return void
  194. */
  195. public function addContainer($name, $label, array $options = [], $parent = '', $alias = '');
  196. /**
  197. * Rename element in layout and layout structure
  198. *
  199. * @param string $oldName
  200. * @param string $newName
  201. * @return bool
  202. */
  203. public function renameElement($oldName, $newName);
  204. /**
  205. * Get element alias by name
  206. *
  207. * @param string $name
  208. * @return bool|string
  209. */
  210. public function getElementAlias($name);
  211. /**
  212. * Remove an element from output
  213. *
  214. * @param string $name
  215. * @return LayoutInterface
  216. */
  217. public function removeOutputElement($name);
  218. /**
  219. * Retrieve messages block
  220. *
  221. * @return \Magento\Framework\View\Element\Messages
  222. */
  223. public function getMessagesBlock();
  224. /**
  225. * Get block singleton
  226. *
  227. * @param string $type
  228. * @return Element\BlockInterface
  229. */
  230. public function getBlockSingleton($type);
  231. /**
  232. * Get property value of an element
  233. *
  234. * @param string $name
  235. * @param string $attribute
  236. * @return mixed
  237. */
  238. public function getElementProperty($name, $attribute);
  239. /**
  240. * Whether specified element is a block
  241. *
  242. * @param string $name
  243. * @return bool
  244. */
  245. public function isBlock($name);
  246. /**
  247. * Checks if element with specified name is container
  248. *
  249. * @param string $name
  250. * @return bool
  251. */
  252. public function isContainer($name);
  253. /**
  254. * Whether the specified element may be manipulated externally
  255. *
  256. * @param string $name
  257. * @return bool
  258. */
  259. public function isManipulationAllowed($name);
  260. /**
  261. * Save block in blocks registry
  262. *
  263. * @param string $name
  264. * @param Element\BlockInterface $block
  265. * @return LayoutInterface
  266. */
  267. public function setBlock($name, $block);
  268. /**
  269. * Check is exists non-cacheable layout elements
  270. *
  271. * @return bool
  272. */
  273. public function isCacheable();
  274. }