Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ScopeValidator.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Store\Model;
7 
12 
14 {
18  protected $scopeResolverPool;
19 
24  {
25  $this->scopeResolverPool = $scopeResolverPool;
26  }
27 
31  public function isValidScope($scope, $scopeId = null)
32  {
33  if ($scope == ScopeConfigInterface::SCOPE_TYPE_DEFAULT && !$scopeId) {
34  return true;
35  }
36 
37  try {
38  $scopeResolver = $this->scopeResolverPool->get($scope);
39  if (!$scopeResolver->getScope($scopeId)->getId()) {
40  return false;
41  }
42  } catch (\InvalidArgumentException $e) {
43  return false;
44  } catch (NoSuchEntityException $e) {
45  return false;
46  }
47 
48  return true;
49  }
50 }
__construct(ScopeResolverPool $scopeResolverPool)
isValidScope($scope, $scopeId=null)