ScopeDefiner.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Config\Model\Config;
  7. use Magento\Framework\App\Config\ScopeConfigInterface;
  8. use Magento\Store\Model\ScopeInterface as StoreScopeInterface;
  9. /**
  10. * System configuration scope
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class ScopeDefiner
  15. {
  16. /**
  17. * Request object
  18. *
  19. * @var \Magento\Framework\App\RequestInterface
  20. */
  21. protected $_request;
  22. /**
  23. * @param \Magento\Framework\App\RequestInterface $request
  24. */
  25. public function __construct(\Magento\Framework\App\RequestInterface $request)
  26. {
  27. $this->_request = $request;
  28. }
  29. /**
  30. * Retrieve current config scope
  31. *
  32. * @return string
  33. */
  34. public function getScope()
  35. {
  36. return $this->_request->getParam(
  37. 'store'
  38. ) ? StoreScopeInterface::SCOPE_STORE : ($this->_request->getParam(
  39. 'website'
  40. ) ? StoreScopeInterface::SCOPE_WEBSITE : ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
  41. }
  42. }