Config.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\TestFramework;
  7. use Magento\Framework\App\Config\MutableScopeConfigInterface;
  8. class Config
  9. {
  10. /**
  11. * @var MutableScopeConfigInterface
  12. */
  13. private $mutableScopeConfig;
  14. /**
  15. * @var array
  16. */
  17. private $configData;
  18. /**
  19. * @param MutableScopeConfigInterface $mutableScopeConfig
  20. * @param string $configPath
  21. */
  22. public function __construct(MutableScopeConfigInterface $mutableScopeConfig, $configPath)
  23. {
  24. $this->mutableScopeConfig = $mutableScopeConfig;
  25. $this->configData = $this->readFile($configPath);
  26. }
  27. /**
  28. * Rewrite config from integration config to global config
  29. */
  30. public function rewriteAdditionalConfig()
  31. {
  32. foreach ($this->configData as $path => $value) {
  33. $this->mutableScopeConfig->setValue($path, $value, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
  34. }
  35. }
  36. /**
  37. * @param string $configPath
  38. * @return array
  39. */
  40. private function readFile($configPath)
  41. {
  42. /** @var array $config */
  43. $config = require $configPath;
  44. return $config;
  45. }
  46. }