|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | + |
| 7 | +declare(strict_types=1); |
| 8 | + |
| 9 | +namespace Magento\Config\Model\Config; |
| 10 | + |
| 11 | +use Magento\Framework\ObjectManager\NoninterceptableInterface; |
| 12 | + |
| 13 | +/** |
| 14 | + * @inheritdoc |
| 15 | + */ |
| 16 | +class StructureLazy extends Structure implements NoninterceptableInterface |
| 17 | +{ |
| 18 | + /** |
| 19 | + * @var Structure\Data |
| 20 | + */ |
| 21 | + private $structureData; |
| 22 | + |
| 23 | + /** |
| 24 | + * @param \Magento\Config\Model\Config\Structure\Data $structureData |
| 25 | + * @param \Magento\Config\Model\Config\Structure\Element\Iterator\Tab $tabIterator |
| 26 | + * @param \Magento\Config\Model\Config\Structure\Element\FlyweightFactory $flyweightFactory |
| 27 | + * @param ScopeDefiner $scopeDefiner |
| 28 | + */ |
| 29 | + public function __construct( |
| 30 | + \Magento\Config\Model\Config\Structure\Data $structureData, |
| 31 | + \Magento\Config\Model\Config\Structure\Element\Iterator\Tab $tabIterator, |
| 32 | + \Magento\Config\Model\Config\Structure\Element\FlyweightFactory $flyweightFactory, |
| 33 | + ScopeDefiner $scopeDefiner |
| 34 | + ) { |
| 35 | + $this->_tabIterator = $tabIterator; |
| 36 | + $this->_flyweightFactory = $flyweightFactory; |
| 37 | + $this->_scopeDefiner = $scopeDefiner; |
| 38 | + $this->structureData = $structureData; |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * @inheritdoc |
| 43 | + */ |
| 44 | + public function getElement($path) |
| 45 | + { |
| 46 | + $this->loadStructureData(); |
| 47 | + return parent::getElement($path); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @inheritdoc |
| 52 | + */ |
| 53 | + public function getTabs() |
| 54 | + { |
| 55 | + $this->loadStructureData(); |
| 56 | + return parent::getTabs(); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * @inheritdoc |
| 61 | + */ |
| 62 | + public function getSectionList() |
| 63 | + { |
| 64 | + $this->loadStructureData(); |
| 65 | + return parent::getSectionList(); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * @inheritdoc |
| 70 | + */ |
| 71 | + public function getElementByConfigPath($path) |
| 72 | + { |
| 73 | + $this->loadStructureData(); |
| 74 | + return parent::getElementByConfigPath($path); |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * @inheritdoc |
| 79 | + */ |
| 80 | + public function getFirstSection() |
| 81 | + { |
| 82 | + $this->loadStructureData(); |
| 83 | + return parent::getTabs(); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * @inheritdoc |
| 88 | + */ |
| 89 | + public function getElementByPathParts(array $pathParts) |
| 90 | + { |
| 91 | + $this->loadStructureData(); |
| 92 | + return parent:: getElementByPathParts($pathParts); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * @inheritdoc |
| 97 | + */ |
| 98 | + public function getFieldPathsByAttribute($attributeName, $attributeValue) |
| 99 | + { |
| 100 | + $this->loadStructureData(); |
| 101 | + return parent::getFieldPathsByAttribute($attributeName, $attributeValue); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * @inheritdoc |
| 106 | + */ |
| 107 | + public function getFieldPaths() |
| 108 | + { |
| 109 | + $this->loadStructureData(); |
| 110 | + return parent::getFieldPaths(); |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Load data |
| 115 | + */ |
| 116 | + private function loadStructureData() |
| 117 | + { |
| 118 | + if ($this->_data === null) { |
| 119 | + $this->_data = $this->structureData->get(); |
| 120 | + } |
| 121 | + } |
| 122 | +} |
0 commit comments