8
8
use InvalidArgumentException ;
9
9
use Magento \Framework \App \Config \ScopeConfigInterface ;
10
10
use Magento \Framework \App \ScopeResolverPool ;
11
- use Magento \Framework \Exception \LocalizedException ;
12
11
use Magento \Framework \Exception \NoSuchEntityException ;
12
+ use Magento \Framework \Exception \ValidatorException ;
13
13
use Magento \Framework \Phrase ;
14
14
15
15
/**
@@ -40,14 +40,14 @@ public function isValid($scope, $scopeCode = null)
40
40
}
41
41
42
42
if ($ scope === ScopeConfigInterface::SCOPE_TYPE_DEFAULT && !empty ($ scopeCode )) {
43
- throw new LocalizedException (new Phrase (
43
+ throw new ValidatorException (new Phrase (
44
44
'The "%1" scope can \'t include a scope code. Try again without entering a scope code. ' ,
45
45
[ScopeConfigInterface::SCOPE_TYPE_DEFAULT ]
46
46
));
47
47
}
48
48
49
49
if (empty ($ scope )) {
50
- throw new LocalizedException (new Phrase ('Enter a scope before proceeding. ' ));
50
+ throw new ValidatorException (new Phrase ('Enter a scope before proceeding. ' ));
51
51
}
52
52
53
53
$ this ->validateScopeCode ($ scopeCode );
@@ -56,9 +56,9 @@ public function isValid($scope, $scopeCode = null)
56
56
$ scopeResolver = $ this ->scopeResolverPool ->get ($ scope );
57
57
$ scopeResolver ->getScope ($ scopeCode )->getId ();
58
58
} catch (InvalidArgumentException $ e ) {
59
- throw new LocalizedException (new Phrase ('The "%1" value doesn \'t exist. Enter another value. ' , [$ scope ]));
59
+ throw new ValidatorException (new Phrase ('The "%1" value doesn \'t exist. Enter another value. ' , [$ scope ]));
60
60
} catch (NoSuchEntityException $ e ) {
61
- throw new LocalizedException (
61
+ throw new ValidatorException (
62
62
new Phrase ('The "%1" value doesn \'t exist. Enter another value. ' , [$ scopeCode ])
63
63
);
64
64
}
@@ -72,16 +72,16 @@ public function isValid($scope, $scopeCode = null)
72
72
*
73
73
* @param string $scopeCode
74
74
* @return void
75
- * @throws LocalizedException if scope code is empty or has a wrong format
75
+ * @throws ValidatorException if scope code is empty or has a wrong format
76
76
*/
77
77
private function validateScopeCode ($ scopeCode )
78
78
{
79
79
if (empty ($ scopeCode )) {
80
- throw new LocalizedException (new Phrase ('Enter a scope code before proceeding. ' ));
80
+ throw new ValidatorException (new Phrase ('Enter a scope code before proceeding. ' ));
81
81
}
82
82
83
83
if (!preg_match ('/^[a-z]+[a-z0-9_]*$/ ' , $ scopeCode )) {
84
- throw new LocalizedException (new Phrase (
84
+ throw new ValidatorException (new Phrase (
85
85
'The scope code can include only lowercase letters (a-z), numbers (0-9) and underscores (_). '
86
86
. 'Also, the first character must be a letter. '
87
87
));
0 commit comments