|
20 | 20 | use Neos\Flow\Mvc\Exception\InvalidArgumentNameException; |
21 | 21 | use Neos\Flow\Mvc\Exception\InvalidArgumentTypeException; |
22 | 22 | use Neos\Flow\Mvc\Exception\NoSuchArgumentException; |
| 23 | +use Neos\Flow\Mvc\Exception\RequiredArgumentMissingException; |
23 | 24 | use Neos\Flow\ObjectManagement\Exception\UnknownObjectException; |
24 | 25 | use Neos\Flow\Property\Exception\FormatNotSupportedException; |
25 | 26 | use Neos\Flow\Property\PropertyMappingConfiguration; |
| 27 | +use Neos\Utility\Arrays; |
26 | 28 | use Neos\Utility\Exception\PropertyNotAccessibleException; |
27 | 29 | use Neos\Utility\ObjectAccess; |
28 | 30 | use Neos\Utility\TypeHandling; |
@@ -436,4 +438,29 @@ protected function applyPaginationMetaToTopLevel( |
436 | 438 |
|
437 | 439 | return $topLevel; |
438 | 440 | } |
| 441 | + |
| 442 | + protected function mapRequestArgumentsToControllerArguments() |
| 443 | + { |
| 444 | + /* @var $argument \Neos\Flow\Mvc\Controller\Argument */ |
| 445 | + foreach ($this->arguments as $argument) { |
| 446 | + $argumentName = $argument->getName(); |
| 447 | + if ($argument->getMapRequestBody()) { |
| 448 | + $body = $this->request->getHttpRequest()->getParsedBody(); |
| 449 | + if (is_array($body)) { |
| 450 | + $body = Arrays::arrayMergeRecursiveOverrule($body, $this->request->getHttpRequest()->getUploadedFiles()); |
| 451 | + } |
| 452 | + if ($argumentName === 'resource' && array_keys($body) === ['resource']) { |
| 453 | + // Backwards compatibility for old-style resource requests |
| 454 | + $body = $body['resource']; |
| 455 | + } |
| 456 | + |
| 457 | + $argument->setValue($body); |
| 458 | + } elseif ($this->request->hasArgument($argumentName)) { |
| 459 | + $argument->setValue($this->request->getArgument($argumentName)); |
| 460 | + } elseif ($argument->isRequired()) { |
| 461 | + throw new RequiredArgumentMissingException('Required argument "' . $argumentName . '" is not set.', 1298012500); |
| 462 | + } |
| 463 | + } |
| 464 | + } |
| 465 | + |
439 | 466 | } |
0 commit comments