InitialConfigSource.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Config;
  7. use Magento\Framework\App\DeploymentConfig\Reader;
  8. use Magento\Framework\DataObject;
  9. /**
  10. * Responsible for reading sources from files: config.dist.php, config.local.php, config.php
  11. */
  12. class InitialConfigSource implements ConfigSourceInterface
  13. {
  14. /**
  15. * @var Reader
  16. */
  17. private $reader;
  18. /**
  19. * @var string
  20. */
  21. private $configType;
  22. /**
  23. * @var string
  24. * @deprecated 101.0.0 Initial configs can not be separated since 2.2.0 version
  25. */
  26. private $fileKey;
  27. /**
  28. * DataProvider constructor.
  29. *
  30. * @param Reader $reader
  31. * @param string $configType
  32. * @param string $fileKey
  33. */
  34. public function __construct(Reader $reader, $configType, $fileKey = null)
  35. {
  36. $this->reader = $reader;
  37. $this->configType = $configType;
  38. $this->fileKey = $fileKey;
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function get($path = '')
  44. {
  45. $data = new DataObject($this->reader->load());
  46. if ($path !== '' && $path !== null) {
  47. $path = '/' . $path;
  48. }
  49. return $data->getData($this->configType . $path) ?: [];
  50. }
  51. }