Store.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Store\Model\Resolver;
  7. class Store implements \Magento\Framework\App\ScopeResolverInterface
  8. {
  9. /**
  10. * @var \Magento\Store\Model\StoreManagerInterface
  11. */
  12. protected $_storeManager;
  13. /**
  14. * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  15. */
  16. public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
  17. {
  18. $this->_storeManager = $storeManager;
  19. }
  20. /**
  21. * {@inheritdoc}
  22. * @throws \Magento\Framework\Exception\State\InitException
  23. */
  24. public function getScope($scopeId = null)
  25. {
  26. $scope = $this->_storeManager->getStore($scopeId);
  27. if (!$scope instanceof \Magento\Framework\App\ScopeInterface) {
  28. throw new \Magento\Framework\Exception\State\InitException(
  29. __('The scope object is invalid. Verify the scope object and try again.')
  30. );
  31. }
  32. return $scope;
  33. }
  34. /**
  35. * Retrieve a list of available stores
  36. *
  37. * @return \Magento\Store\Model\Store[]
  38. */
  39. public function getScopes()
  40. {
  41. return $this->_storeManager->getStores();
  42. }
  43. }