/**
  * Render a link to a specific module
  *
  * @param string $path Target module path
  * @param string $action Target module action
  * @param array $arguments Arguments
  * @param string $section The anchor to be added to the URI
  * @param string $format The requested format, e.g. ".html"
  * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
  * @param boolean $addQueryString If set, the current query parameters will be kept in the URI
  * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
  * @return string The rendered link
  * @throws \TYPO3\Fluid\Core\ViewHelper\Exception
  */
 public function render($path, $action = null, $arguments = array(), $section = '', $format = '', array $additionalParams = array(), $addQueryString = false, array $argumentsToBeExcludedFromQueryString = array())
 {
     $this->setMainRequestToUriBuilder();
     $modifiedArguments = array('module' => $path);
     if ($arguments !== array()) {
         $modifiedArguments['moduleArguments'] = $arguments;
     }
     if ($action !== null) {
         $modifiedArguments['moduleArguments']['@action'] = $action;
     }
     try {
         return $this->uriBuilder->reset()->setSection($section)->setCreateAbsoluteUri(true)->setArguments($additionalParams)->setAddQueryString($addQueryString)->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)->setFormat($format)->uriFor('index', $modifiedArguments, 'Backend\\Module', 'TYPO3.Neos');
     } catch (\TYPO3\Flow\Exception $exception) {
         throw new \TYPO3\Fluid\Core\ViewHelper\Exception($exception->getMessage(), $exception->getCode(), $exception);
     }
 }
 /**
  * @test
  */
 public function resetSetsAllOptionsToTheirDefaultValue()
 {
     $this->uriBuilder->setArguments(array('test' => 'arguments'))->setSection('testSection')->setFormat('someFormat')->setCreateAbsoluteUri(TRUE)->setAddQueryString(TRUE)->setArgumentsToBeExcludedFromQueryString(array('test' => 'addQueryStringExcludeArguments'));
     $this->uriBuilder->reset();
     $this->assertEquals(array(), $this->uriBuilder->getArguments());
     $this->assertEquals('', $this->uriBuilder->getSection());
     $this->assertEquals('', $this->uriBuilder->getFormat());
     $this->assertEquals(FALSE, $this->uriBuilder->getCreateAbsoluteUri());
     $this->assertEquals(FALSE, $this->uriBuilder->getAddQueryString());
     $this->assertEquals(array(), $this->uriBuilder->getArgumentsToBeExcludedFromQueryString());
 }
 /**
  * @return void
  * @throws ForwardException
  */
 public function executeInternal()
 {
     $formRuntime = $this->finisherContext->getFormRuntime();
     $request = $formRuntime->getRequest()->getMainRequest();
     $this->uriBuilder->setRequest($request);
     $uri = null;
     $path = $this->parseOption('path');
     $action = $this->parseOption('action');
     $format = $this->parseOption('format');
     $modifiedArguments = ['module' => $path];
     if ($action !== null) {
         $modifiedArguments['moduleArguments']['@action'] = $action;
     }
     $jobIdentifier = $formRuntime->getRequest()->getArgument('jobIdentifier');
     $options = $formRuntime->getRequest()->getArguments();
     unset($options['jobIdentifier']);
     $this->executeJob($jobIdentifier, $options);
     $uri = $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->setFormat($format)->uriFor('index', $modifiedArguments, 'Backend\\Module', 'TYPO3.Neos');
     $this->redirect($uri);
 }
 /**
  * Calculates the dimensions of the thumbnail to be generated and returns the thumbnail URI.
  * In case of Images this is a thumbnail of the image, in case of other assets an icon representation.
  *
  * @param AssetInterface $asset
  * @param ThumbnailConfiguration $configuration
  * @param ActionRequest $request Request argument must be provided for asynchronous thumbnails
  * @return array|null Array with keys "width", "height" and "src" if the thumbnail generation work or null
  * @throws AssetServiceException
  */
 public function getThumbnailUriAndSizeForAsset(AssetInterface $asset, ThumbnailConfiguration $configuration, ActionRequest $request = null)
 {
     $thumbnailImage = $this->thumbnailService->getThumbnail($asset, $configuration);
     if (!$thumbnailImage instanceof ImageInterface) {
         return null;
     }
     $resource = $thumbnailImage->getResource();
     if ($thumbnailImage instanceof Thumbnail) {
         $staticResource = $thumbnailImage->getStaticResource();
         if ($configuration->isAsync() === true && $resource === null && $staticResource === null) {
             if ($request === null) {
                 throw new AssetServiceException('Request argument must be provided for async thumbnails.', 1447660835);
             }
             $this->uriBuilder->setRequest($request->getMainRequest());
             $uri = $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->uriFor('thumbnail', array('thumbnail' => $thumbnailImage), 'Thumbnail', 'TYPO3.Media');
         } else {
             $uri = $this->thumbnailService->getUriForThumbnail($thumbnailImage);
         }
     } else {
         $uri = $this->resourceManager->getPublicPersistentResourceUri($resource);
     }
     return array('width' => $thumbnailImage->getWidth(), 'height' => $thumbnailImage->getHeight(), 'src' => $uri);
 }
 /**
  * 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);
 }
Exemple #6
0
 /**
  * @param ActionRequest $request
  * @return string
  */
 protected function buildActionUri(ActionRequest $request)
 {
     $packageKey = $this->parseOption('package');
     $controllerName = $this->parseOption('controller');
     $actionName = $this->parseOption('action');
     $arguments = $this->parseOption('arguments');
     $subpackageKey = null;
     if ($packageKey !== null && strpos($packageKey, '\\') !== false) {
         list($packageKey, $subpackageKey) = explode('\\', $packageKey, 2);
     }
     $uriBuilder = new UriBuilder();
     $uriBuilder->setRequest($request);
     $uriBuilder->reset();
     $uri = $uriBuilder->uriFor($actionName, $arguments, $controllerName, $packageKey, $subpackageKey);
     return $uri;
 }
 /**
  * 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);
 }