Returns an Array of arguments and their values
public getArguments ( ) : array | ||
return | array | Array of arguments and their values (which may be arguments and values as well) |
/** * @param Request $httpRequest * @param array $matchResults * @return ActionRequest */ protected function createActionRequest(Request $httpRequest, array $matchResults = null) { $actionRequest = new ActionRequest($httpRequest); if ($matchResults !== null) { $requestArguments = $actionRequest->getArguments(); $mergedArguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $matchResults); $actionRequest->setArguments($mergedArguments); } return $actionRequest; }
/** * @param \Neos\Form\Core\Model\Page $page * @return \Neos\Error\Messages\Result * @internal */ protected function mapAndValidatePage(\Neos\Form\Core\Model\Page $page) { $result = new \Neos\Error\Messages\Result(); $requestArguments = $this->request->getArguments(); $propertyPathsForWhichPropertyMappingShouldHappen = array(); $registerPropertyPaths = function ($propertyPath) use(&$propertyPathsForWhichPropertyMappingShouldHappen) { $propertyPathParts = explode('.', $propertyPath); $accumulatedPropertyPathParts = array(); foreach ($propertyPathParts as $propertyPathPart) { $accumulatedPropertyPathParts[] = $propertyPathPart; $temporaryPropertyPath = implode('.', $accumulatedPropertyPathParts); $propertyPathsForWhichPropertyMappingShouldHappen[$temporaryPropertyPath] = $temporaryPropertyPath; } }; foreach ($page->getElementsRecursively() as $element) { $value = \Neos\Utility\Arrays::getValueByPath($requestArguments, $element->getIdentifier()); $element->onSubmit($this, $value); $this->formState->setFormValue($element->getIdentifier(), $value); $registerPropertyPaths($element->getIdentifier()); } // The more parts the path has, the more early it is processed usort($propertyPathsForWhichPropertyMappingShouldHappen, function ($a, $b) { return substr_count($b, '.') - substr_count($a, '.'); }); $processingRules = $this->formDefinition->getProcessingRules(); foreach ($propertyPathsForWhichPropertyMappingShouldHappen as $propertyPath) { if (isset($processingRules[$propertyPath])) { $processingRule = $processingRules[$propertyPath]; $value = $this->formState->getFormValue($propertyPath); try { $value = $processingRule->process($value); } catch (\Neos\Flow\Property\Exception $exception) { throw new \Neos\Form\Exception\PropertyMappingException('Failed to process FormValue at "' . $propertyPath . '" from "' . gettype($value) . '" to "' . $processingRule->getDataType() . '"', 1355218921, $exception); } $result->forProperty($propertyPath)->merge($processingRule->getProcessingMessages()); $this->formState->setFormValue($propertyPath, $value); } } return $result; }
/** * @test */ public function allArgumentsCanBeSetOrRetrievedAtOnce() { $arguments = ['foo' => 'fooValue', 'bar' => 'barValue']; $this->actionRequest->setArguments($arguments); $this->assertEquals($arguments, $this->actionRequest->getArguments()); }
/** * Redirects the request to another action and / or controller. * * Redirect will be sent to the client which then performs another request to the new URI. * * NOTE: This method only supports web requests and will throw an exception * if used with other request types. * * @param ActionRequest $request The request to redirect to * @param integer $delay (optional) The delay in seconds. Default is no delay. * @param integer $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other" * @return void * @throws StopActionException * @see forwardToRequest() * @api */ protected function redirectToRequest(ActionRequest $request, $delay = 0, $statusCode = 303) { $packageKey = $request->getControllerPackageKey(); $subpackageKey = $request->getControllerSubpackageKey(); if ($subpackageKey !== null) { $packageKey .= '\\' . $subpackageKey; } $this->redirect($request->getControllerActionName(), $request->getControllerName(), $packageKey, $request->getArguments(), $delay, $statusCode, $request->getFormat()); }
/** * Merges specified arguments with arguments from request. * * If $this->request is no sub request, request arguments will only be merged if $this->addQueryString is set. * Otherwise all request arguments except for the ones prefixed with the current request argument namespace will * be merged. Additionally special arguments (PackageKey, SubpackageKey, ControllerName & Action) are merged. * * The argument provided through the $arguments parameter always overrule the request * arguments. * * The request hierarchy is structured as follows: * root (HTTP) > main (Action) > sub (Action) > sub sub (Action) * * @param array $arguments * @return array */ protected function mergeArgumentsWithRequestArguments(array $arguments) { if ($this->request !== $this->request->getMainRequest()) { $subRequest = $this->request; while ($subRequest instanceof ActionRequest) { $requestArguments = (array) $subRequest->getArguments(); // Reset arguments for the request that is bound to this UriBuilder instance if ($subRequest === $this->request) { if ($this->addQueryString === false) { $requestArguments = []; } else { foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) { unset($requestArguments[$argumentToBeExcluded]); } } } else { // Remove all arguments of the current sub request if it's namespaced if ($this->request->getArgumentNamespace() !== '') { $requestNamespace = $this->getRequestNamespacePath($this->request); if ($this->addQueryString === false) { $requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace); } else { foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) { $requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace . '.' . $argumentToBeExcluded); } } } } // Merge special arguments (package, subpackage, controller & action) from main request $requestPackageKey = $subRequest->getControllerPackageKey(); if (!empty($requestPackageKey)) { $requestArguments['@package'] = $requestPackageKey; } $requestSubpackageKey = $subRequest->getControllerSubpackageKey(); if (!empty($requestSubpackageKey)) { $requestArguments['@subpackage'] = $requestSubpackageKey; } $requestControllerName = $subRequest->getControllerName(); if (!empty($requestControllerName)) { $requestArguments['@controller'] = $requestControllerName; } $requestActionName = $subRequest->getControllerActionName(); if (!empty($requestActionName)) { $requestArguments['@action'] = $requestActionName; } if (count($requestArguments) > 0) { $requestArguments = $this->addNamespaceToArguments($requestArguments, $subRequest); $arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments); } $subRequest = $subRequest->getParentRequest(); } } elseif ($this->addQueryString === true) { $requestArguments = $this->request->getArguments(); foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) { unset($requestArguments[$argumentToBeExcluded]); } if ($requestArguments !== []) { $arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments); } } return $arguments; }