Path.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * System Configuration Path Mapper
  8. */
  9. namespace Magento\Config\Model\Config\Structure\Mapper;
  10. /**
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Path extends \Magento\Config\Model\Config\Structure\AbstractMapper
  15. {
  16. /**
  17. * Apply map
  18. *
  19. * @param array $data
  20. * @return array
  21. */
  22. public function map(array $data)
  23. {
  24. if ($this->_hasValue('config/system/sections', $data)) {
  25. foreach ($data['config']['system']['sections'] as &$sectionConfig) {
  26. if ($this->_hasValue('children', $sectionConfig)) {
  27. foreach ($sectionConfig['children'] as &$groupConfig) {
  28. $groupConfig = $this->_processConfig($groupConfig, $sectionConfig);
  29. }
  30. }
  31. }
  32. }
  33. return $data;
  34. }
  35. /**
  36. * Process configuration
  37. *
  38. * @param array $elementConfig
  39. * @param array $parentConfig
  40. * @return array
  41. */
  42. protected function _processConfig(array $elementConfig, array $parentConfig)
  43. {
  44. $parentPath = $this->_hasValue('path', $parentConfig) ? $parentConfig['path'] . '/' : '';
  45. $parentPath .= $parentConfig['id'];
  46. $elementConfig['path'] = $parentPath;
  47. if ($this->_hasValue('children', $elementConfig)) {
  48. foreach ($elementConfig['children'] as &$subConfig) {
  49. $subConfig = $this->_processConfig($subConfig, $elementConfig);
  50. }
  51. }
  52. return $elementConfig;
  53. }
  54. }