47 class Structure implements \Magento\Config\Model\Config\Structure\SearchInterface
113 private $mappedPaths;
127 $this->_data = $structureData->get();
128 $this->_tabIterator = $tabIterator;
129 $this->_flyweightFactory = $flyweightFactory;
130 $this->_scopeDefiner = $scopeDefiner;
140 if (isset($this->_data[
'sections'])) {
141 foreach ($this->_data[
'sections'] as $sectionId => $section) {
142 if (isset($section[
'tab']) && $section[
'tab']) {
143 $this->_data[
'tabs'][$section[
'tab']][
'children'][$sectionId] = $section;
146 $this->_tabIterator->setElements($this->_data[
'tabs'], $this->_scopeDefiner->getScope());
160 if (empty($this->sectionList)) {
161 foreach ($this->_data[
'sections'] as $sectionId => $section) {
162 if (array_key_exists(
'children', $section) && is_array($section[
'children'])) {
163 foreach ($section[
'children'] as $childId => $child) {
164 $this->sectionList[$sectionId .
'_' . $childId] =
true;
194 if (isset($allPaths[
$path])) {
207 public function getFirstSection()
212 $tab = $tabs->current();
213 $tab->getChildren()->rewind();
214 if (!$tab->getChildren()->current()->isVisible()) {
218 return $tab->getChildren()->current();
229 $path = implode(
'_', $pathParts);
230 if (isset($this->_elements[
$path])) {
231 return $this->_elements[
$path];
238 foreach ($pathParts as $pathPart) {
241 $children = array_key_exists(
'children', $child) ? $child[
'children'] : [];
247 $this->_elements[
$path] = $this->_flyweightFactory->create($child[
'_elementType']);
248 $this->_elements[
$path]->setData($child, $this->_scopeDefiner->getScope());
249 return $this->_elements[
$path];
260 switch (count($pathParts)) {
262 $elementType =
'section';
265 $elementType =
'group';
268 $elementType =
'field';
270 $elementId = array_pop($pathParts);
271 return [
'id' => $elementId,
'path' => implode(
'/', $pathParts),
'_elementType' => $elementType];
284 if (empty($this->_data[
'sections'])) {
288 foreach ($this->_data[
'sections'] as $section) {
289 if (!isset($section[
'children'])) {
292 foreach ($section[
'children'] as
$group) {
293 if (isset(
$group[
'children'])) {
323 if (isset($field[
'children'])) {
326 $parentPath .
'/' . $field[
'id'],
330 }
elseif (isset($field[$attributeName]) && $field[$attributeName] == $attributeValue) {
331 $result[] = $parentPath .
'/' . $field[
'id'];
376 $sections = !empty($this->_data[
'sections']) ? $this->_data[
'sections'] : [];
378 if (!$this->mappedPaths) {
379 $this->mappedPaths = $this->getFieldsRecursively($sections);
382 return $this->mappedPaths;
391 private function getFieldsRecursively(array $elements = [])
397 $result = array_replace_recursive(
399 $this->getFieldsRecursively(
$element[
'children'])
404 $configPath = isset(
$element[
'config_path']) ?
$element[
'config_path'] : $structurePath;
406 if (!isset(
$result[$configPath])) {
410 $result[$configPath][] = $structurePath;
elseif(isset( $params[ 'redirect_parent']))
getElementByPathParts(array $pathParts)
_getGroupFieldPathsByAttribute(array $fields, $parentPath, $attributeName, $attributeValue)
_createEmptyElement(array $pathParts)
getFieldPathsByAttribute($attributeName, $attributeValue)
__construct(\Magento\Config\Model\Config\Structure\Data $structureData, \Magento\Config\Model\Config\Structure\Element\Iterator\Tab $tabIterator, \Magento\Config\Model\Config\Structure\Element\FlyweightFactory $flyweightFactory, ScopeDefiner $scopeDefiner)
getElementByConfigPath($path)