Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StoreScopeProvider.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Store\Model;
8 
12 
17 {
21  private $storeManager;
22 
26  private $scopeFactory;
27 
34  public function __construct(
35  StoreManagerInterface $storeManager,
36  ScopeFactory $scopeFactory
37  ) {
38  $this->storeManager = $storeManager;
39  $this->scopeFactory = $scopeFactory;
40  }
41 
48  public function getContext($entityType, $entityData = [])
49  {
50  if (isset($entityData[Store::STORE_ID])) {
51  $value = $entityData[Store::STORE_ID];
52  } else {
53  $value = (int)$this->storeManager->getStore(true)->getId();
54  }
55 
56  $identifier = Store::STORE_ID;
57  $fallback = null;
59  $fallback = $this->scopeFactory->create($identifier, Store::DEFAULT_STORE_ID);
60  }
61  return $this->scopeFactory->create($identifier, $value, $fallback);
62  }
63 }
$storeManager
$value
Definition: gender.phtml:16
__construct(StoreManagerInterface $storeManager, ScopeFactory $scopeFactory)
getContext($entityType, $entityData=[])