| @@ 146-159 (lines=14) @@ | ||
| 143 | $this->hooks[$name][self::EXTRACT_OUTPUT][] = $outputExtractor; |
|
| 144 | } |
|
| 145 | ||
| 146 | public function validateArguments($names, $args, AnnotationData $annotationData) |
|
| 147 | { |
|
| 148 | $validators = $this->getValidators($names, $annotationData); |
|
| 149 | foreach ($validators as $validator) { |
|
| 150 | $validated = $this->callValidator($validator, $args, $annotationData); |
|
| 151 | if (is_object($validated)) { |
|
| 152 | return $validated; |
|
| 153 | } |
|
| 154 | if (is_array($validated)) { |
|
| 155 | $args = $validated; |
|
| 156 | } |
|
| 157 | } |
|
| 158 | return $args; |
|
| 159 | } |
|
| 160 | ||
| 161 | /** |
|
| 162 | * Process result and decide what to do with it. |
|
| @@ 85-104 (lines=20) @@ | ||
| 82 | } |
|
| 83 | } |
|
| 84 | ||
| 85 | public function validateRunAndAlter( |
|
| 86 | $names, |
|
| 87 | $commandCallback, |
|
| 88 | $args, |
|
| 89 | AnnotationData $annotationData |
|
| 90 | ) { |
|
| 91 | // Validators return any object to signal a validation error; |
|
| 92 | // if the return an array, it replaces the arguments. |
|
| 93 | $validated = $this->hookManager()->validateArguments($names, $args, $annotationData); |
|
| 94 | if (is_object($validated)) { |
|
| 95 | return $validated; |
|
| 96 | } |
|
| 97 | if (is_array($validated)) { |
|
| 98 | $args = $validated; |
|
| 99 | } |
|
| 100 | ||
| 101 | // Run the command, alter the results, and then handle output and status |
|
| 102 | $result = $this->runCommandCallback($commandCallback, $args); |
|
| 103 | return $this->processResults($names, $result, $args, $annotationData); |
|
| 104 | } |
|
| 105 | ||
| 106 | public function processResults($names, $result, $args, $annotationData) |
|
| 107 | { |
|