Returns the top level request: the HTTP request object
public getHttpRequest ( ) : |
||
Résultat |
/** * 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(); }
/** * @test */ public function getHttpRequestReturnsTheHttpRequestWhichIsTheRootOfAllActionRequests() { $anotherActionRequest = new ActionRequest($this->actionRequest); $yetAnotherActionRequest = new ActionRequest($anotherActionRequest); $this->assertSame($this->mockHttpRequest, $this->actionRequest->getHttpRequest()); $this->assertSame($this->mockHttpRequest, $yetAnotherActionRequest->getHttpRequest()); $this->assertSame($this->mockHttpRequest, $anotherActionRequest->getHttpRequest()); }
/** * Updates the password credential from the POST vars, if the POST parameters * are available. Sets the authentication status to AUTHENTICATION_NEEDED, if credentials have been sent. * * Note: You need to send the password in this POST parameter: * __authentication[TYPO3][Flow][Security][Authentication][Token][PasswordToken][password] * * @param ActionRequest $actionRequest The current action request * @return void */ public function updateCredentials(ActionRequest $actionRequest) { if ($actionRequest->getHttpRequest()->getMethod() !== 'POST') { return; } $postArguments = $actionRequest->getInternalArguments(); $password = ObjectAccess::getPropertyPath($postArguments, '__authentication.TYPO3.Flow.Security.Authentication.Token.PasswordToken.password'); if (!empty($password)) { $this->credentials['password'] = $password; $this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED); } }
/** * Updates the username and password credentials from the HTTP authorization header. * Sets the authentication status to AUTHENTICATION_NEEDED, if the header has been * sent, to NO_CREDENTIALS_GIVEN if no authorization header was there. * * @param ActionRequest $actionRequest The current action request instance * @return void */ public function updateCredentials(ActionRequest $actionRequest) { $authorizationHeader = $actionRequest->getHttpRequest()->getHeaders()->get('Authorization'); if (substr($authorizationHeader, 0, 5) === 'Basic') { $credentials = base64_decode(substr($authorizationHeader, 6)); $this->credentials['username'] = substr($credentials, 0, strpos($credentials, ':')); $this->credentials['password'] = substr($credentials, strpos($credentials, ':') + 1); $this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED); } else { $this->credentials = ['username' => null, 'password' => null]; $this->authenticationStatus = self::NO_CREDENTIALS_GIVEN; } }
/** * Builds the URI * * @param array $arguments optional URI arguments. Will be merged with $this->arguments with precedence to $arguments * @return string The URI * @api */ public function build(array $arguments = []) { $arguments = Arrays::arrayMergeRecursiveOverrule($this->arguments, $arguments); $arguments = $this->mergeArgumentsWithRequestArguments($arguments); $uri = $this->router->resolve($arguments); $this->lastArguments = $arguments; if (!$this->environment->isRewriteEnabled()) { $uri = 'index.php/' . $uri; } $httpRequest = $this->request->getHttpRequest(); if ($this->createAbsoluteUri === true) { $uri = $httpRequest->getBaseUri() . $uri; } elseif (!$this->createRelativePaths) { $uri = $httpRequest->getScriptRequestPath() . $uri; } if ($this->section !== '') { $uri .= '#' . $this->section; } return $uri; }
/** * Returns the top level request: the HTTP request object * * @return HttpRequest * @api */ public function getHttpRequest() { if ($this->rootRequest === null) { $this->rootRequest = $this->parentRequest instanceof HttpRequest ? $this->parentRequest : $this->parentRequest->getHttpRequest(); } return $this->rootRequest; }