AbstractScopeConfig.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Config\Controller\Adminhtml\System\Config;
  7. use Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker;
  8. /**
  9. * @api
  10. * @since 100.0.2
  11. */
  12. abstract class AbstractScopeConfig extends \Magento\Config\Controller\Adminhtml\System\AbstractConfig
  13. {
  14. /**
  15. * @var \Magento\Config\Model\Config
  16. */
  17. protected $_backendConfig;
  18. /**
  19. * @param \Magento\Backend\App\Action\Context $context
  20. * @param \Magento\Config\Model\Config\Structure $configStructure
  21. * @param ConfigSectionChecker $sectionChecker
  22. * @param \Magento\Config\Model\Config $backendConfig
  23. */
  24. public function __construct(
  25. \Magento\Backend\App\Action\Context $context,
  26. \Magento\Config\Model\Config\Structure $configStructure,
  27. ConfigSectionChecker $sectionChecker,
  28. \Magento\Config\Model\Config $backendConfig
  29. ) {
  30. $this->_backendConfig = $backendConfig;
  31. parent::__construct($context, $configStructure, $sectionChecker);
  32. }
  33. /**
  34. * Sets scope for backend config
  35. *
  36. * @param string $sectionId
  37. * @return bool
  38. */
  39. protected function isSectionAllowed($sectionId)
  40. {
  41. $website = $this->getRequest()->getParam('website');
  42. $store = $this->getRequest()->getParam('store');
  43. if ($store) {
  44. $this->_backendConfig->setStore($store);
  45. } elseif ($website) {
  46. $this->_backendConfig->setWebsite($website);
  47. }
  48. return parent::isSectionAllowed($sectionId);
  49. }
  50. }