9 use InvalidArgumentException;
26 private $scopeResolverPool;
33 $this->scopeResolverPool = $scopeResolverPool;
39 public function isValid($scope, $scopeCode =
null)
47 'The "%1" scope can\'t include a scope code. Try again without entering a scope code.',
56 $this->validateScopeCode($scopeCode);
59 $scopeResolver = $this->scopeResolverPool->get($scope);
60 $scopeResolver->getScope($scopeCode)->getId();
61 }
catch (InvalidArgumentException $e) {
63 new Phrase(
'The "%1" value doesn\'t exist. Enter another value and try again.', [$scope])
67 new Phrase(
'The "%1" value doesn\'t exist. Enter another value and try again.', [$scopeCode])
82 private function validateScopeCode($scopeCode)
84 if (empty($scopeCode)) {
88 if (!preg_match(
'/^[a-z]+[a-z0-9_]*$/', $scopeCode)) {
90 'The scope code can include only lowercase letters (a-z), numbers (0-9) and underscores (_). ' 91 .
'Also, the first character must be a letter.'
__construct(ScopeResolverPool $scopeResolverPool)
isValid($scope, $scopeCode=null)