Layout.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Ui\Component;
  7. use Magento\Framework\View\Layout\Pool as LayoutPool;
  8. use Magento\Framework\View\Element\Template;
  9. use Magento\Framework\View\Element\UiComponent\LayoutInterface;
  10. use Magento\Framework\View\Element\UiComponent\ContextInterface;
  11. /**
  12. * Class Layout
  13. */
  14. class Layout extends AbstractComponent
  15. {
  16. const NAME = 'layout';
  17. /**
  18. * @var LayoutPool
  19. */
  20. protected $layoutPool;
  21. /**
  22. * @var string
  23. */
  24. protected $type;
  25. /**
  26. * @var LayoutInterface
  27. */
  28. protected $layoutTypeObject;
  29. /**
  30. * @var array
  31. */
  32. protected $structure = [];
  33. /**
  34. * Constructor
  35. *
  36. * @param ContextInterface $context
  37. * @param LayoutPool $layoutPool
  38. * @param string $type
  39. * @param array $components
  40. * @param array $data
  41. */
  42. public function __construct(
  43. ContextInterface $context,
  44. LayoutPool $layoutPool,
  45. $type,
  46. array $components = [],
  47. array $data = []
  48. ) {
  49. $this->layoutPool = $layoutPool;
  50. $this->type = $type;
  51. parent::__construct($context, $components, $data);
  52. }
  53. /**
  54. * Get component name
  55. *
  56. * @return string
  57. */
  58. public function getComponentName()
  59. {
  60. return static::NAME;
  61. }
  62. /**
  63. * Register component and build layout structure
  64. *
  65. * @inheritdoc
  66. */
  67. public function prepare()
  68. {
  69. $this->layoutTypeObject = $this->layoutPool->create($this->type);
  70. $this->structure = $this->layoutTypeObject->build($this);
  71. parent::prepare();
  72. }
  73. /**
  74. * @return array
  75. */
  76. public function getStructure()
  77. {
  78. return $this->structure;
  79. }
  80. }