@@ 43-52 (lines=10) @@ | ||
40 | $errors = []; |
|
41 | $operation = $this->description->getOperation($command->getName()); |
|
42 | ||
43 | foreach ($operation->getParams() as $name => $schema) { |
|
44 | $value = $command[$name]; |
|
45 | if (! $this->validator->validate($schema, $value)) { |
|
46 | $errors = array_merge($errors, $this->validator->getErrors()); |
|
47 | } elseif ($value !== $command[$name]) { |
|
48 | // Update the config value if it changed and no validation |
|
49 | // errors were encountered |
|
50 | $command[$name] = $value; |
|
51 | } |
|
52 | } |
|
53 | ||
54 | if ($params = $operation->getAdditionalParameters()) { |
|
55 | foreach ($command->toArray() as $name => $value) { |
|
@@ 55-69 (lines=15) @@ | ||
52 | } |
|
53 | ||
54 | if ($params = $operation->getAdditionalParameters()) { |
|
55 | foreach ($command->toArray() as $name => $value) { |
|
56 | // It's only additional if it isn't defined in the schema |
|
57 | if (! $operation->hasParam($name)) { |
|
58 | // Always set the name so that error messages are useful |
|
59 | $params->setName($name); |
|
60 | if (! $this->validator->validate($params, $value)) { |
|
61 | $errors = array_merge($errors, $this->validator->getErrors()); |
|
62 | } elseif ($value !== $command[$name]) { |
|
63 | $command[$name] = $value; |
|
64 | } |
|
65 | } |
|
66 | } |
|
67 | } |
|
68 | ||
69 | if ($errors) { |
|
70 | throw new CommandException('Validation errors: ' . implode("\n", $errors), $command); |
|
71 | } |
|
72 |