ModularConfigSource.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Config\App\Config\Source;
  7. use Magento\Framework\App\Config\ConfigSourceInterface;
  8. use Magento\Framework\DataObject;
  9. use Magento\Framework\App\Config\Initial\Reader;
  10. /**
  11. * Class for retrieving initial configuration from modules
  12. *
  13. * @api
  14. * @since 100.1.2
  15. */
  16. class ModularConfigSource implements ConfigSourceInterface
  17. {
  18. /**
  19. * @var Reader
  20. */
  21. private $reader;
  22. /**
  23. * @param Reader $reader
  24. */
  25. public function __construct(Reader $reader)
  26. {
  27. $this->reader = $reader;
  28. }
  29. /**
  30. * Get initial data
  31. *
  32. * @param string $path Format is scope type and scope code separated by slash: e.g. "type/code"
  33. * @return array
  34. * @since 100.1.2
  35. */
  36. public function get($path = '')
  37. {
  38. $data = new DataObject($this->reader->read());
  39. if ($path !== '') {
  40. $path = '/' . $path;
  41. }
  42. return $data->getData('data' . $path) ?: [];
  43. }
  44. }