5
5
*/
6
6
namespace Magento \Backend \Model \Menu \Item ;
7
7
8
- use BadMethodCallException ;
9
- use InvalidArgumentException ;
10
- use Zend_Validate ;
11
-
12
8
/**
13
9
* Class Validator
14
10
*
@@ -35,7 +31,7 @@ class Validator
35
31
/**
36
32
* The list of primitive validators
37
33
*
38
- * @var Zend_Validate[]
34
+ * @var \ Zend_Validate[]
39
35
*/
40
36
protected $ _validators = [];
41
37
@@ -44,17 +40,17 @@ class Validator
44
40
*/
45
41
public function __construct ()
46
42
{
47
- $ idValidator = new Zend_Validate ();
43
+ $ idValidator = new \ Zend_Validate ();
48
44
$ idValidator ->addValidator (new \Zend_Validate_StringLength (['min ' => 3 ]));
49
45
$ idValidator ->addValidator (new \Zend_Validate_Regex ('/^[A-Za-z0-9\/:_]+$/ ' ));
50
46
51
- $ resourceValidator = new Zend_Validate ();
47
+ $ resourceValidator = new \ Zend_Validate ();
52
48
$ resourceValidator ->addValidator (new \Zend_Validate_StringLength (['min ' => 8 ]));
53
49
$ resourceValidator ->addValidator (
54
50
new \Zend_Validate_Regex ('/^[A-Z][A-Za-z0-9]+_[A-Z][A-Za-z0-9]+::[A-Za-z_0-9]+$/ ' )
55
51
);
56
52
57
- $ attributeValidator = new Zend_Validate ();
53
+ $ attributeValidator = new \ Zend_Validate ();
58
54
$ attributeValidator ->addValidator (new \Zend_Validate_StringLength (['min ' => 3 ]));
59
55
$ attributeValidator ->addValidator (new \Zend_Validate_Regex ('/^[A-Za-z0-9\/_\-]+$/ ' ));
60
56
@@ -77,8 +73,8 @@ public function __construct()
77
73
*
78
74
* @param array $data
79
75
* @return void
80
- * @throws InvalidArgumentException
81
- * @throws BadMethodCallException
76
+ * @throws \ InvalidArgumentException
77
+ * @throws \ BadMethodCallException
82
78
*/
83
79
public function validate ($ data )
84
80
{
@@ -111,13 +107,13 @@ private function checkMenuItemIsRemoved($data)
111
107
*
112
108
* @param array $data
113
109
*
114
- * @throws BadMethodCallException
110
+ * @throws \ BadMethodCallException
115
111
*/
116
112
private function assertContainsRequiredParameters ($ data )
117
113
{
118
114
foreach ($ this ->_required as $ param ) {
119
115
if (!isset ($ data [$ param ])) {
120
- throw new BadMethodCallException ('Missing required param ' . $ param );
116
+ throw new \ BadMethodCallException ('Missing required param ' . $ param );
121
117
}
122
118
}
123
119
}
@@ -126,12 +122,12 @@ private function assertContainsRequiredParameters($data)
126
122
* Check that menu item id is not used
127
123
*
128
124
* @param string $id
129
- * @throws InvalidArgumentException
125
+ * @throws \ InvalidArgumentException
130
126
*/
131
127
private function assertIdentifierIsNotUsed ($ id )
132
128
{
133
129
if (array_search ($ id , $ this ->_ids ) !== false ) {
134
- throw new InvalidArgumentException ('Item with id ' . $ id . ' already exists ' );
130
+ throw new \ InvalidArgumentException ('Item with id ' . $ id . ' already exists ' );
135
131
}
136
132
}
137
133
@@ -140,7 +136,7 @@ private function assertIdentifierIsNotUsed($id)
140
136
*
141
137
* @param string $param
142
138
* @param mixed $value
143
- * @throws InvalidArgumentException
139
+ * @throws \ InvalidArgumentException
144
140
*/
145
141
private function validateMenuItemParameter ($ param , $ value )
146
142
{
@@ -156,7 +152,7 @@ private function validateMenuItemParameter($param, $value)
156
152
return ;
157
153
}
158
154
159
- throw new InvalidArgumentException (
155
+ throw new \ InvalidArgumentException (
160
156
"Param " . $ param . " doesn't pass validation: " . implode (
161
157
'; ' ,
162
158
$ validator ->getMessages ()
@@ -170,16 +166,16 @@ private function validateMenuItemParameter($param, $value)
170
166
* @param string $param
171
167
* @param mixed $value
172
168
* @return void
173
- * @throws InvalidArgumentException
169
+ * @throws \ InvalidArgumentException
174
170
*/
175
171
public function validateParam ($ param , $ value )
176
172
{
177
173
if (in_array ($ param , $ this ->_required ) && $ value === null ) {
178
- throw new InvalidArgumentException ('Param ' . $ param . ' is required ' );
174
+ throw new \ InvalidArgumentException ('Param ' . $ param . ' is required ' );
179
175
}
180
176
181
177
if ($ value !== null && isset ($ this ->_validators [$ param ]) && !$ this ->_validators [$ param ]->isValid ($ value )) {
182
- throw new InvalidArgumentException (
178
+ throw new \ InvalidArgumentException (
183
179
'Param ' . $ param . ' doesn \'t pass validation: ' . implode (
184
180
'; ' ,
185
181
$ this ->_validators [$ param ]->getMessages ()
0 commit comments