MutableScopeConfig.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Application configuration object. Used to access configuration when application is installed.
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\TestFramework\App;
  9. use Magento\Framework\App\Config\MutableScopeConfigInterface;
  10. use Magento\Framework\App\Config\ScopeConfigInterface;
  11. use Magento\TestFramework\ObjectManager;
  12. /**
  13. * @inheritdoc
  14. */
  15. class MutableScopeConfig implements MutableScopeConfigInterface
  16. {
  17. /**
  18. * @var Config
  19. */
  20. private $testAppConfig;
  21. /**
  22. * @param string $path
  23. * @param string $scopeType
  24. * @param null $scopeCode
  25. * @return bool
  26. */
  27. public function isSetFlag($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null)
  28. {
  29. return $this->getTestAppConfig()->isSetFlag($path, $scopeType, $scopeCode);
  30. }
  31. /**
  32. * @inheritdoc
  33. */
  34. public function getValue($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null)
  35. {
  36. return $this->getTestAppConfig()->getValue($path, $scopeType, $scopeCode);
  37. }
  38. /**
  39. * @inheritdoc
  40. */
  41. public function setValue(
  42. $path,
  43. $value,
  44. $scopeType = \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
  45. $scopeCode = null
  46. ) {
  47. return $this->getTestAppConfig()->setValue($path, $value, $scopeType, $scopeCode);
  48. }
  49. /**
  50. * Clean app config cache
  51. *
  52. * @param string|null $type
  53. * @return void
  54. */
  55. public function clean()
  56. {
  57. $this->getTestAppConfig()->clean();
  58. }
  59. /**
  60. * Retrieve test app config instance
  61. *
  62. * @return \Magento\TestFramework\App\Config
  63. */
  64. private function getTestAppConfig()
  65. {
  66. if (!$this->testAppConfig) {
  67. $this->testAppConfig = ObjectManager::getInstance()->get(ScopeConfigInterface::class);
  68. }
  69. return $this->testAppConfig;
  70. }
  71. }