Config.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Default application path for backend area
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Backend\App;
  9. use Magento\Config\App\Config\Type\System;
  10. use Magento\Framework\App\Config\ScopeConfigInterface;
  11. /**
  12. * Backend config accessor.
  13. */
  14. class Config implements ConfigInterface
  15. {
  16. /**
  17. * @var \Magento\Framework\App\Config
  18. */
  19. protected $appConfig;
  20. /**
  21. * @var array
  22. */
  23. private $data;
  24. /**
  25. * @param \Magento\Framework\App\Config $appConfig
  26. * @return void
  27. */
  28. public function __construct(\Magento\Framework\App\Config $appConfig)
  29. {
  30. $this->appConfig = $appConfig;
  31. }
  32. /**
  33. * @inheritdoc
  34. */
  35. public function getValue($path)
  36. {
  37. if (isset($this->data[$path])) {
  38. return $this->data[$path];
  39. }
  40. $configPath = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
  41. if ($path) {
  42. $configPath .= '/' . $path;
  43. }
  44. return $this->appConfig->get(System::CONFIG_TYPE, $configPath);
  45. }
  46. /**
  47. * @inheritdoc
  48. */
  49. public function setValue($path, $value)
  50. {
  51. $this->data[$path] = $value;
  52. }
  53. /**
  54. * @inheritdoc
  55. */
  56. public function isSetFlag($path)
  57. {
  58. $configPath = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
  59. if ($path) {
  60. $configPath .= '/' . $path;
  61. }
  62. return (bool) $this->appConfig->get(System::CONFIG_TYPE, $configPath);
  63. }
  64. }