ConfigProvider.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Deploy\App\Mode;
  7. /**
  8. * This class is responsible for providing configuration while switching application mode
  9. */
  10. class ConfigProvider
  11. {
  12. /**
  13. * Configuration for combinations of $currentMode and $targetMode
  14. * For example:
  15. * [
  16. * 'developer' => [
  17. * 'production' => [
  18. * {{setting_path}} => {{setting_value}}
  19. * ]
  20. * ]
  21. * ]
  22. *
  23. * @var array
  24. */
  25. private $config;
  26. /**
  27. * @param array $config
  28. */
  29. public function __construct(array $config = [])
  30. {
  31. $this->config = $config;
  32. }
  33. /**
  34. * Provide configuration while switching from $currentMode to $targetMode
  35. * This method used in \Magento\Deploy\Model\Mode::setStoreMode
  36. *
  37. * For example: while switching from developer mode to production mode
  38. * need to turn off 'dev/debug/debug_logging' setting in this case method
  39. * will return array
  40. * [
  41. * {{setting_path}} => {{setting_value}}
  42. * ]
  43. *
  44. * @param string $currentMode
  45. * @param string $targetMode
  46. * @return array
  47. */
  48. public function getConfigs($currentMode, $targetMode)
  49. {
  50. if (isset($this->config[$currentMode][$targetMode])) {
  51. return $this->config[$currentMode][$targetMode];
  52. }
  53. return [];
  54. }
  55. }