Пример #1
0
 /**
  * Construct
  */
 public function __construct()
 {
     $httpRequest = \TYPO3\Flow\Http\Request::createFromEnvironment();
     $actionRequest = new \TYPO3\Flow\Mvc\ActionRequest($httpRequest);
     $this->uriBuilder = new \TYPO3\Flow\Mvc\Routing\UriBuilder();
     $this->uriBuilder->setRequest($actionRequest);
 }
 /**
  * @return ControllerContext
  */
 protected function createControllerContextFromEnvironment()
 {
     $httpRequest = Request::createFromEnvironment();
     /** @var ActionRequest $request */
     $request = $httpRequest->createActionRequest();
     $uriBuilder = new UriBuilder();
     $uriBuilder->setRequest($request);
     return new ControllerContext($request, new Response(), new Arguments(array()), $uriBuilder);
 }
Пример #3
0
 /**
  * @test
  */
 public function buildAddsActionNameFromRootRequestIfRequestIsOfTypeSubRequest()
 {
     $expectedArguments = array('@action' => 'RootRequestActionName');
     $this->mockMainRequest->expects($this->once())->method('getControllerActionName')->will($this->returnValue('RootRequestActionName'));
     $this->mockMainRequest->expects($this->any())->method('getArguments')->will($this->returnValue(array()));
     $this->uriBuilder->setRequest($this->mockSubRequest);
     $this->uriBuilder->build();
     $this->assertEquals($expectedArguments, $this->uriBuilder->getLastArguments());
 }
Пример #4
0
 /**
  * @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);
 }
Пример #5
0
 /**
  * Returns the body and header sections created by the clients configured for the given page name.
  *
  * @param \TYPO3\Flow\Mvc\RequestInterface $request Request object
  * @param string $pageName Name of the configured page
  * @return array Associative list with body and header output separated by client name
  */
 public function getSections(\TYPO3\Flow\Mvc\RequestInterface $request, $pageName)
 {
     $this->uriBuilder->setRequest($request);
     $tmplPaths = $this->aimeos->get()->getCustomPaths('client/html/templates');
     $pagesConfig = $this->settings['page'];
     $result = array('aibody' => array(), 'aiheader' => array());
     $context = $this->context->get($request);
     $langid = $context->getLocale()->getLanguageId();
     $view = $this->view->create($context, $this->uriBuilder, $tmplPaths, $request, $langid);
     $context->setView($view);
     if (isset($pagesConfig[$pageName])) {
         foreach ((array) $pagesConfig[$pageName] as $clientName) {
             $client = \Aimeos\Client\Html\Factory::createClient($context, $tmplPaths, $clientName);
             $client->setView(clone $view);
             $client->process();
             $varName = str_replace('/', '_', $clientName);
             $result['aibody'][$varName] = $client->getBody();
             $result['aiheader'][$varName] = $client->getHeader();
         }
     }
     return $result;
 }
 /**
  * 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);
 }
 /**
  * Action for creating a temporary account
  *
  * @param Registration $registration
  * @return void
  */
 public function createAccountAction(Registration $registration)
 {
     $accountIdentifier = $registration->getUsername();
     $existingAccount = $this->accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, 'Typo3BackendProvider');
     if ($existingAccount !== NULL) {
         $this->addFlashMessage('An account with the username "%s" already exists.', 'Account already exists', Message::SEVERITY_ERROR, array($accountIdentifier));
         $this->forward('newAccount');
     }
     $this->createTemporaryAccount($accountIdentifier, $registration->getPassword(), $registration->getFirstName(), $registration->getLastName());
     $uriBuilder = new UriBuilder();
     $uriBuilder->setRequest($this->request->getParentRequest());
     $redirectUri = $uriBuilder->setCreateAbsoluteUri(TRUE)->uriFor('index', array('username' => $accountIdentifier), 'Login', 'TYPO3.Neos');
     $this->redirectToUri($redirectUri);
 }
 /**
  * Starts the authentication: Redirect to login page
  *
  * @param \TYPO3\Flow\Http\Request $request The current request
  * @param \TYPO3\Flow\Http\Response $response The current response
  * @return void
  * @throws MissingConfigurationException
  */
 public function startAuthentication(Request $request, Response $response)
 {
     if (isset($this->options['routeValues'])) {
         $routeValues = $this->options['routeValues'];
         if (!is_array($routeValues)) {
             throw new MissingConfigurationException(sprintf('The configuration for the WebRedirect authentication entry point is incorrect. "routeValues" must be an array, got "%s".', gettype($routeValues)), 1345040415);
         }
         $actionRequest = new ActionRequest($request);
         $this->uriBuilder->setRequest($actionRequest);
         $actionName = $this->extractRouteValue($routeValues, '@action');
         $controllerName = $this->extractRouteValue($routeValues, '@controller');
         $packageKey = $this->extractRouteValue($routeValues, '@package');
         $subPackageKey = $this->extractRouteValue($routeValues, '@subpackage');
         $uri = $this->uriBuilder->setCreateAbsoluteUri(true)->uriFor($actionName, $routeValues, $controllerName, $packageKey, $subPackageKey);
     } elseif (isset($this->options['uri'])) {
         $uri = strpos($this->options['uri'], '://') !== false ? $this->options['uri'] : $request->getBaseUri() . $this->options['uri'];
     } else {
         throw new MissingConfigurationException('The configuration for the WebRedirect authentication entry point is incorrect or missing. You need to specify either the target "uri" or "routeValues".', 1237282583);
     }
     $response->setContent(sprintf('<html><head><meta http-equiv="refresh" content="0;url=%s"/></head></html>', htmlentities($uri, ENT_QUOTES, 'utf-8')));
     $response->setStatus(303);
     $response->setHeader('Location', $uri);
 }
 /**
  * Helper to build a TypoScript view object
  *
  * @return TypoScriptView
  */
 protected function buildView()
 {
     $view = new TypoScriptView();
     $httpRequest = Request::createFromEnvironment();
     $request = $httpRequest->createActionRequest();
     $uriBuilder = new UriBuilder();
     $uriBuilder->setRequest($request);
     $this->controllerContext = new ControllerContext($request, new Response(), new Arguments(array()), $uriBuilder);
     $view->setControllerContext($this->controllerContext);
     $view->disableFallbackView();
     $view->setPackageKey('TYPO3.TypoScript');
     $view->setTypoScriptPathPattern(__DIR__ . '/Fixtures/TypoScript');
     $view->assign('fixtureDirectory', __DIR__ . '/Fixtures/');
     return $view;
 }
Пример #10
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;
 }
 /**
  * Initializes the controller
  *
  * This method should be called by the concrete processRequest() method.
  *
  * @param \TYPO3\Flow\Mvc\RequestInterface $request
  * @param \TYPO3\Flow\Mvc\ResponseInterface $response
  * @throws \TYPO3\Flow\Mvc\Exception\UnsupportedRequestTypeException
  */
 protected function initializeController(\TYPO3\Flow\Mvc\RequestInterface $request, \TYPO3\Flow\Mvc\ResponseInterface $response)
 {
     if (!$request instanceof ActionRequest) {
         throw new \TYPO3\Flow\Mvc\Exception\UnsupportedRequestTypeException(get_class($this) . ' only supports action requests – requests of type "' . get_class($request) . '" given.', 1187701131);
     }
     $this->request = $request;
     $this->request->setDispatched(true);
     $this->response = $response;
     $this->uriBuilder = new UriBuilder();
     $this->uriBuilder->setRequest($this->request);
     $this->arguments = new Arguments(array());
     $this->controllerContext = new ControllerContext($this->request, $this->response, $this->arguments, $this->uriBuilder);
     $mediaType = $request->getHttpRequest()->getNegotiatedMediaType($this->supportedMediaTypes);
     if ($mediaType === null) {
         $this->throwStatus(406);
     }
     if ($request->getFormat() === null) {
         $this->request->setFormat(MediaTypes::getFilenameExtensionFromMediaType($mediaType));
     }
 }
Пример #12
0
 /**
  * The Resource Information most likely needs an UriBuilder, so having a
  * ControllerContext in place might come in handy.
  *
  * @return void
  */
 protected function initializeControllerContext()
 {
     $request = new ActionRequest(Request::createFromEnvironment());
     $request->setDispatched(true);
     $response = new Response();
     $uriBuilder = new UriBuilder();
     $uriBuilder->setRequest($request);
     $arguments = new Arguments(array());
     $this->controllerContext = new ControllerContext($request, $response, $arguments, $uriBuilder);
 }
 /**
  * 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);
 }
 /**
  * Extracted out to this method in order to be better unit-testable.
  *
  * @return void
  */
 protected function setMainRequestToUriBuilder()
 {
     $mainRequest = $this->controllerContext->getRequest()->getMainRequest();
     $this->uriBuilder->setRequest($mainRequest);
 }
 /**
  * Initiates the StandaloneView by creating the required ControllerContext
  *
  * @return void
  */
 public function initializeObject()
 {
     if ($this->request === NULL) {
         $httpRequest = Request::createFromEnvironment();
         $this->request = $this->objectManager->get(\TYPO3\Flow\Mvc\ActionRequest::class, $httpRequest);
     }
     $uriBuilder = new UriBuilder();
     $uriBuilder->setRequest($this->request);
     $this->setControllerContext(new ControllerContext($this->request, new Response(), new Arguments(array()), $uriBuilder));
 }
 /**
  * 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');
 }
Пример #17
0
 /**
  * Initiates the StandaloneView by creating the required ControllerContext
  *
  * @return void
  */
 public function initializeObject()
 {
     if ($this->request === NULL) {
         $httpRequest = Request::createFromEnvironment();
         $this->request = $httpRequest->createActionRequest();
     }
     $uriBuilder = new UriBuilder();
     $uriBuilder->setRequest($this->request);
     $this->setControllerContext(new ControllerContext($this->request, new Response(), new Arguments(array()), $uriBuilder, $this->flashMessageContainer));
 }