Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Group.php
Go to the documentation of this file.
1 <?php
7 
8 class Group implements ReaderInterface
9 {
13  protected $groupRepository;
14 
18  protected $storeRepository;
19 
24  public function __construct(
25  \Magento\Store\Api\StoreRepositoryInterface $storeRepository,
26  \Magento\Store\Api\GroupRepositoryInterface $groupRepository
27  ) {
28  $this->groupRepository = $groupRepository;
29  $this->storeRepository = $storeRepository;
30  }
31 
35  public function getAllowedStoreIds($scopeCode)
36  {
37  $stores = [];
38  foreach ($this->storeRepository->getList() as $store) {
39  if ($store->isActive() && (int) $store->getGroupId() === $scopeCode) {
40  $stores[] = $store->getId();
41  }
42  }
43  return $stores;
44  }
45 
49  public function getDefaultStoreId($scopeCode)
50  {
51  return $this->groupRepository->get($scopeCode)->getDefaultStoreId();
52  }
53 }
__construct(\Magento\Store\Api\StoreRepositoryInterface $storeRepository, \Magento\Store\Api\GroupRepositoryInterface $groupRepository)
Definition: Group.php:24