Writer.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Application config storage writer
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Framework\App\Config\Storage;
  9. use Magento\Framework\App\Config\ScopeConfigInterface;
  10. class Writer implements \Magento\Framework\App\Config\Storage\WriterInterface
  11. {
  12. /**
  13. * Resource model of config data
  14. *
  15. * @var \Magento\Framework\App\Config\ConfigResource\ConfigInterface
  16. */
  17. protected $_resource;
  18. /**
  19. * @param \Magento\Framework\App\Config\ConfigResource\ConfigInterface $resource
  20. */
  21. public function __construct(\Magento\Framework\App\Config\ConfigResource\ConfigInterface $resource)
  22. {
  23. $this->_resource = $resource;
  24. }
  25. /**
  26. * Delete config value from storage
  27. *
  28. * @param string $path
  29. * @param string $scope
  30. * @param int $scopeId
  31. * @return void
  32. */
  33. public function delete($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0)
  34. {
  35. $this->_resource->deleteConfig(rtrim($path, '/'), $scope, $scopeId);
  36. }
  37. /**
  38. * Save config value to storage
  39. *
  40. * @param string $path
  41. * @param string $value
  42. * @param string $scope
  43. * @param int $scopeId
  44. * @return void
  45. */
  46. public function save($path, $value, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0)
  47. {
  48. $this->_resource->saveConfig(rtrim($path, '/'), $value, $scope, $scopeId);
  49. }
  50. }