ConfigFilePool.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Config\File;
  7. /**
  8. * Stores file key to file name config
  9. * @api
  10. * @since 100.0.2
  11. */
  12. class ConfigFilePool
  13. {
  14. const APP_CONFIG = 'app_config';
  15. const APP_ENV = 'app_env';
  16. /**
  17. * @deprecated Magento does not support custom config file pools since 2.2.0 version
  18. */
  19. const LOCAL = 'local';
  20. /**
  21. * @deprecated Magento does not support custom config file pools since 2.2.0 version
  22. */
  23. const DIST = 'dist';
  24. /**
  25. * Default files for configuration
  26. *
  27. * @var array
  28. */
  29. private $applicationConfigFiles = [
  30. self::APP_CONFIG => 'config.php',
  31. self::APP_ENV => 'env.php',
  32. ];
  33. /**
  34. * Initial files for configuration
  35. *
  36. * @var array
  37. * @deprecated 101.0.0 Magento does not support custom config file pools since 2.2.0 version
  38. */
  39. private $initialConfigFiles = [
  40. self::DIST => [
  41. self::APP_CONFIG => 'config.dist.php',
  42. self::APP_ENV => 'env.dist.php',
  43. ],
  44. self::LOCAL => [
  45. self::APP_CONFIG => 'config.local.php',
  46. self::APP_ENV => 'env.local.php',
  47. ]
  48. ];
  49. /**
  50. * Constructor
  51. *
  52. * @param array $additionalConfigFiles
  53. */
  54. public function __construct($additionalConfigFiles = [])
  55. {
  56. $this->applicationConfigFiles = array_merge($this->applicationConfigFiles, $additionalConfigFiles);
  57. }
  58. /**
  59. * Returns application config files.
  60. *
  61. * @return array
  62. */
  63. public function getPaths()
  64. {
  65. return $this->applicationConfigFiles;
  66. }
  67. /**
  68. * Returns file path by config key
  69. *
  70. * @param string $fileKey
  71. * @return string
  72. * @throws \Exception
  73. */
  74. public function getPath($fileKey)
  75. {
  76. if (!isset($this->applicationConfigFiles[$fileKey])) {
  77. throw new \Exception('File config key does not exist.');
  78. }
  79. return $this->applicationConfigFiles[$fileKey];
  80. }
  81. /**
  82. * Returns application initial config files.
  83. *
  84. * @return array
  85. * @deprecated 101.0.0 Magento does not support custom config file pools since 2.2.0 version
  86. * @since 100.1.3
  87. */
  88. public function getInitialFilePools()
  89. {
  90. return $this->initialConfigFiles;
  91. }
  92. /**
  93. * Retrieve all config file pools.
  94. *
  95. * @param string $pool
  96. * @return array
  97. * @deprecated 101.0.0 Magento does not support custom config file pools since 2.2.0 version
  98. * @since 100.1.3
  99. */
  100. public function getPathsByPool($pool)
  101. {
  102. return $this->initialConfigFiles[$pool];
  103. }
  104. }