Website.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 Website 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(
  17. \Magento\Store\Model\StoreManagerInterface $storeManager
  18. ) {
  19. $this->_storeManager = $storeManager;
  20. }
  21. /**
  22. * {@inheritdoc}
  23. * @throws \Magento\Framework\Exception\State\InitException
  24. */
  25. public function getScope($scopeId = null)
  26. {
  27. $scope = $this->_storeManager->getWebsite($scopeId);
  28. if (!($scope instanceof \Magento\Framework\App\ScopeInterface)) {
  29. throw new \Magento\Framework\Exception\State\InitException(
  30. __('The scope object is invalid. Verify the scope object and try again.')
  31. );
  32. }
  33. return $scope;
  34. }
  35. /**
  36. * Retrieve a list of available websites
  37. *
  38. * @return \Magento\Store\Model\Website[]
  39. */
  40. public function getScopes()
  41. {
  42. return $this->_storeManager->getWebsites();
  43. }
  44. }