@@ 110-129 (lines=20) @@ | ||
107 | } |
|
108 | } |
|
109 | ||
110 | public function validateRunAndAlter( |
|
111 | $names, |
|
112 | $commandCallback, |
|
113 | $args, |
|
114 | AnnotationData $annotationData |
|
115 | ) { |
|
116 | // Validators return any object to signal a validation error; |
|
117 | // if the return an array, it replaces the arguments. |
|
118 | $validated = $this->hookManager()->validateArguments($names, $args, $annotationData); |
|
119 | if (is_object($validated)) { |
|
120 | return $validated; |
|
121 | } |
|
122 | if (is_array($validated)) { |
|
123 | $args = $validated; |
|
124 | } |
|
125 | ||
126 | // Run the command, alter the results, and then handle output and status |
|
127 | $result = $this->runCommandCallback($commandCallback, $args); |
|
128 | return $this->processResults($names, $result, $args, $annotationData); |
|
129 | } |
|
130 | ||
131 | public function processResults($names, $result, $args, $annotationData) |
|
132 | { |
@@ 315-328 (lines=14) @@ | ||
312 | } |
|
313 | } |
|
314 | ||
315 | public function validateArguments($names, $args, AnnotationData $annotationData) |
|
316 | { |
|
317 | $validators = $this->getValidators($names, $annotationData); |
|
318 | foreach ($validators as $validator) { |
|
319 | $validated = $this->callValidator($validator, $args, $annotationData); |
|
320 | if (is_object($validated)) { |
|
321 | return $validated; |
|
322 | } |
|
323 | if (is_array($validated)) { |
|
324 | $args = $validated; |
|
325 | } |
|
326 | } |
|
327 | return $args; |
|
328 | } |
|
329 | ||
330 | /** |
|
331 | * Process result and decide what to do with it. |