/**
  * @test
  */
 public function uriForSetsFormatArgumentIfSpecified()
 {
     $expectedArguments = array('@action' => 'index', '@controller' => 'somecontroller', '@package' => 'somepackage', '@format' => 'someformat');
     $this->uriBuilder->setFormat('SomeFormat');
     $this->uriBuilder->uriFor('index', array(), 'SomeController', 'SomePackage');
     $this->assertEquals($expectedArguments, $this->uriBuilder->getLastArguments());
 }
 /**
  * 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 \TYPO3\Flow\Mvc\Exception\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', 'TYPO3.Neos');
 }
 /**
  * Creates a new blog post node
  *
  * @return void
  */
 public function createAction()
 {
     /** @var NodeInterface $blogDocumentNode */
     $blogDocumentNode = $this->request->getInternalArgument('__documentNode');
     if ($blogDocumentNode === NULL) {
         return 'Error: The Blog Post Plugin cannot determine the current document node. Please make sure to include this plugin only by inserting it into a page / document.';
     }
     $contentContext = $blogDocumentNode->getContext();
     $nodeTemplate = new NodeTemplate();
     $nodeTemplate->setNodeType($this->nodeTypeManager->getNodeType('RobertLemke.Plugin.Blog:Post'));
     $nodeTemplate->setProperty('title', 'A new blog post');
     $nodeTemplate->setProperty('datePublished', $contentContext->getCurrentDateTime());
     $slug = uniqid('post');
     $postNode = $blogDocumentNode->createNodeFromTemplate($nodeTemplate, $slug);
     $currentlyFirstPostNode = $blogDocumentNode->getPrimaryChildNode();
     if ($currentlyFirstPostNode !== NULL) {
         // FIXME This currently doesn't work, probably due to some TYPO3CR bug / misconception
         $postNode->moveBefore($currentlyFirstPostNode);
     }
     $mainRequest = $this->request->getMainRequest();
     $mainUriBuilder = new UriBuilder();
     $mainUriBuilder->setRequest($mainRequest);
     $mainUriBuilder->setFormat('html');
     $uri = $mainUriBuilder->reset()->setCreateAbsoluteUri(TRUE)->uriFor('show', array('node' => $postNode));
     $this->redirectToUri($uri);
 }