Skip to content

Commit 7a09d4b

Browse files
Merge pull request #41 from netlogix/fix/map-uploaded-resources
2 parents 6f66ae2 + 1ce002a commit 7a09d4b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Classes/Controller/GenericModelController.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
use Neos\Flow\Mvc\Exception\InvalidArgumentNameException;
2121
use Neos\Flow\Mvc\Exception\InvalidArgumentTypeException;
2222
use Neos\Flow\Mvc\Exception\NoSuchArgumentException;
23+
use Neos\Flow\Mvc\Exception\RequiredArgumentMissingException;
2324
use Neos\Flow\ObjectManagement\Exception\UnknownObjectException;
2425
use Neos\Flow\Property\Exception\FormatNotSupportedException;
2526
use Neos\Flow\Property\PropertyMappingConfiguration;
27+
use Neos\Utility\Arrays;
2628
use Neos\Utility\Exception\PropertyNotAccessibleException;
2729
use Neos\Utility\ObjectAccess;
2830
use Neos\Utility\TypeHandling;
@@ -436,4 +438,29 @@ protected function applyPaginationMetaToTopLevel(
436438

437439
return $topLevel;
438440
}
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+
439466
}

0 commit comments

Comments
 (0)