Layout.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Pricing\Render;
  7. use Magento\Framework\View\LayoutFactory;
  8. use Magento\Framework\View\LayoutInterface;
  9. /**
  10. * Pricing render's layout model
  11. */
  12. class Layout
  13. {
  14. /**
  15. * Layout Interface
  16. *
  17. * @var LayoutInterface
  18. */
  19. protected $layout;
  20. /**
  21. * Constructor
  22. *
  23. * @param LayoutFactory $layoutFactory
  24. * @param LayoutInterface $generalLayout
  25. */
  26. public function __construct(
  27. LayoutFactory $layoutFactory,
  28. \Magento\Framework\View\LayoutInterface $generalLayout
  29. ) {
  30. $this->layout = $layoutFactory->create(['cacheable' => $generalLayout->isCacheable()]);
  31. }
  32. /**
  33. * Add handle(s) to layout
  34. *
  35. * @param string|string[] $handle
  36. * @return void
  37. */
  38. public function addHandle($handle)
  39. {
  40. $this->layout->getUpdate()->addHandle($handle);
  41. }
  42. /**
  43. * Load layout
  44. *
  45. * @return void
  46. */
  47. public function loadLayout()
  48. {
  49. $this->layout->getUpdate()->load();
  50. $this->layout->generateXml();
  51. $this->layout->generateElements();
  52. }
  53. /**
  54. * Obtain block object
  55. *
  56. * @param string $name
  57. * @return \Magento\Framework\View\Element\AbstractBlock
  58. */
  59. public function getBlock($name)
  60. {
  61. return $this->layout->getBlock($name);
  62. }
  63. }