Checks if an argument of the given name exists (is set)
public hasArgument ( string $argumentName ) : boolean | ||
$argumentName | string | Name of the argument to check |
리턴 | boolean | TRUE if the argument is set, otherwise FALSE |
/** * Determines the action method and assures that the method exists. * * @return string The action method name * @throws NoSuchActionException if the action specified in the request object does not exist (and if there's no default action either). */ protected function resolveActionMethodName() { if ($this->request->getControllerActionName() === 'index') { $actionName = 'index'; switch ($this->request->getHttpRequest()->getMethod()) { case 'HEAD': case 'GET': $actionName = $this->request->hasArgument($this->resourceArgumentName) ? 'show' : 'list'; break; case 'POST': $actionName = 'create'; break; case 'PUT': if (!$this->request->hasArgument($this->resourceArgumentName)) { $this->throwStatus(400, null, 'No resource specified'); } $actionName = 'update'; break; case 'DELETE': if (!$this->request->hasArgument($this->resourceArgumentName)) { $this->throwStatus(400, null, 'No resource specified'); } $actionName = 'delete'; break; } $this->request->setControllerActionName($actionName); } return parent::resolveActionMethodName(); }
/** * Maps arguments delivered by the request object to the local controller arguments. * * @return void * @throws RequiredArgumentMissingException * @api */ protected function mapRequestArgumentsToControllerArguments() { foreach ($this->arguments as $argument) { $argumentName = $argument->getName(); if ($this->request->hasArgument($argumentName)) { $argument->setValue($this->request->getArgument($argumentName)); } elseif ($argument->isRequired()) { throw new RequiredArgumentMissingException('Required argument "' . $argumentName . '" is not set.', 1298012500); } } }
/** * @test */ public function pluginArgumentsAreHandledSeparately() { $this->actionRequest->setArgument('--typo3-flow-foo-viewhelper-paginate', ['@controller' => 'Foo', 'page' => 5]); $this->assertFalse($this->actionRequest->hasArgument('--typo3-flow-foo-viewhelper-paginate')); $this->assertEquals(['typo3-flow-foo-viewhelper-paginate' => ['@controller' => 'Foo', 'page' => 5]], $this->actionRequest->getPluginArguments()); }