Structure.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Layout\Generator;
  7. use Magento\Framework\View\Layout\Pool as LayoutPool;
  8. use Magento\Framework\View\Element\UiComponentInterface;
  9. use Magento\Framework\View\Element\UiComponent\LayoutInterface;
  10. /**
  11. * Class Structure
  12. */
  13. class Structure
  14. {
  15. /**
  16. * @var LayoutPool
  17. */
  18. protected $layoutPool;
  19. /**
  20. * Constructor
  21. *
  22. * @param LayoutPool $layoutPool
  23. */
  24. public function __construct(LayoutPool $layoutPool)
  25. {
  26. $this->layoutPool = $layoutPool;
  27. }
  28. /**
  29. * Build component structure and retrieve
  30. *
  31. * @param UiComponentInterface $component
  32. * @return array
  33. */
  34. public function generate(UiComponentInterface $component)
  35. {
  36. /** @var LayoutInterface $layout */
  37. if (!$layoutDefinition = $component->getData('layout')) {
  38. $layoutDefinition = ['type' => 'generic'];
  39. }
  40. $layout = $this->layoutPool->create($layoutDefinition['type'], $layoutDefinition);
  41. return $layout->build($component);
  42. }
  43. }