MutableScopeConfig.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\Framework\App;
  9. use Magento\Framework\App\Config\MutableScopeConfigInterface;
  10. use Magento\Framework\App\Config\ScopeConfigInterface;
  11. /**
  12. * @inheritdoc
  13. */
  14. class MutableScopeConfig extends Config implements MutableScopeConfigInterface
  15. {
  16. /**
  17. * @var array
  18. */
  19. private $data;
  20. /**
  21. * @inheritdoc
  22. */
  23. public function getValue(
  24. $path = null,
  25. $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
  26. $scopeCode = null
  27. ) {
  28. if (isset($this->data[$scope][$scopeCode][$path])) {
  29. return $this->data[$scope][$scopeCode][$path];
  30. }
  31. return parent::getValue($path, $scope, $scopeCode);
  32. }
  33. /**
  34. * Set config value in the corresponding config scope
  35. *
  36. * @param string $path
  37. * @param mixed $value
  38. * @param string $scope
  39. * @param null|string $scopeCode
  40. * @return void
  41. */
  42. public function setValue(
  43. $path,
  44. $value,
  45. $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
  46. $scopeCode = null
  47. ) {
  48. $this->data[$scope][$scopeCode][$path] = $value;
  49. }
  50. /**
  51. * @inheritdoc
  52. */
  53. public function clean()
  54. {
  55. $this->data = null;
  56. parent::clean();
  57. }
  58. }