/** * @test */ public function uriForSetsFormatArgumentIfSpecified() { $expectedArguments = ['@action' => 'index', '@controller' => 'somecontroller', '@package' => 'somepackage', '@format' => 'someformat']; $this->uriBuilder->setFormat('SomeFormat'); $this->uriBuilder->uriFor('index', [], 'SomeController', 'SomePackage'); $this->assertEquals($expectedArguments, $this->uriBuilder->getLastArguments()); }
/** * Creates an UriBuilder instance for the current request * * @return UriBuilder */ protected function getUriBuilder() { if ($this->uriBuilder === null) { $httpRequest = Request::createFromEnvironment(); $actionRequest = new ActionRequest($httpRequest); $this->uriBuilder = new UriBuilder(); $this->uriBuilder->setRequest($actionRequest); $this->uriBuilder->setFormat('html')->setCreateAbsoluteUri(false); } return $this->uriBuilder; }
/** * 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 string $actionName Name of the action to forward to * @param string $controllerName Unqualified object name of the controller to forward to. If not specified, the current controller is used. * @param string $packageKey Key of the package containing the controller to forward to. If not specified, the current package is assumed. * @param array $arguments Array of arguments for the target action * @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" * @param string $format The format to use for the redirect URI * @return void * @throws StopActionException * @see forward() * @api */ protected function redirect($actionName, $controllerName = null, $packageKey = null, array $arguments = null, $delay = 0, $statusCode = 303, $format = null) { if ($packageKey !== null && strpos($packageKey, '\\') !== false) { list($packageKey, $subpackageKey) = explode('\\', $packageKey, 2); } else { $subpackageKey = null; } $this->uriBuilder->reset(); if ($format === null) { $this->uriBuilder->setFormat($this->request->getFormat()); } else { $this->uriBuilder->setFormat($format); } $uri = $this->uriBuilder->setCreateAbsoluteUri(true)->uriFor($actionName, $arguments, $controllerName, $packageKey, $subpackageKey); $this->redirectToUri($uri, $delay, $statusCode); }
/** * Returns a specific URI string to redirect to after the logout; or NULL if there is none. * In case of NULL, it's the responsibility of the AuthenticationController where to redirect, * most likely to the LoginController's index action. * * @param ActionRequest $actionRequest * @return string A possible redirection URI, if any */ public function getAfterLogoutRedirectionUri(ActionRequest $actionRequest) { $lastVisitedNode = $this->getLastVisitedNode('live'); if ($lastVisitedNode === null) { return null; } $uriBuilder = new UriBuilder(); $uriBuilder->setRequest($actionRequest); $uriBuilder->setFormat('html'); $uriBuilder->setCreateAbsoluteUri(true); return $uriBuilder->uriFor('show', array('node' => $lastVisitedNode), 'Frontend\\Node', 'Neos.Neos'); }