Store.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Store\Model\StoreResolver;
  7. class Store implements ReaderInterface
  8. {
  9. /**
  10. * @var \Magento\Store\Api\StoreRepositoryInterface
  11. */
  12. protected $storeRepository;
  13. /**
  14. * @param \Magento\Store\Api\StoreRepositoryInterface $storeRepository
  15. */
  16. public function __construct(\Magento\Store\Api\StoreRepositoryInterface $storeRepository)
  17. {
  18. $this->storeRepository = $storeRepository;
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function getAllowedStoreIds($scopeCode)
  24. {
  25. $stores = [];
  26. foreach ($this->storeRepository->getList() as $store) {
  27. if ($store->isActive()) {
  28. $stores[] = $store->getId();
  29. }
  30. }
  31. return $stores;
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function getDefaultStoreId($scopeCode)
  37. {
  38. return $this->storeRepository->get($scopeCode)->getId();
  39. }
  40. }