/**
  * Renders an RSS feed
  *
  * @return string
  */
 public function rssAction()
 {
     /** @var NodeInterface $blogDocumentNode */
     $rssDocumentNode = $this->request->getInternalArgument('__documentNode');
     if ($rssDocumentNode === 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.';
     }
     $blogDocumentNode = $rssDocumentNode->getParent();
     $uriBuilder = new UriBuilder();
     $uriBuilder->setRequest($this->request->getMainRequest());
     $uriBuilder->setCreateAbsoluteUri(TRUE);
     if ($this->settings['feed']['uri'] !== '') {
         $feedUri = $this->settings['feed']['uri'];
     } else {
         $uriBuilder->setFormat('xml');
         $feedUri = $uriBuilder->uriFor('show', array('node' => $rssDocumentNode), 'Frontend\\Node', 'TYPO3.Neos');
     }
     $channel = new Channel();
     $channel->setTitle($this->settings['feed']['title']);
     $channel->setDescription($this->settings['feed']['description']);
     $channel->setFeedUri($feedUri);
     $channel->setWebsiteUri($this->request->getHttpRequest()->getBaseUri());
     $channel->setLanguage((string) $this->i18nService->getConfiguration()->getCurrentLocale());
     foreach ($blogDocumentNode->getChildNodes('RobertLemke.Plugin.Blog:Post') as $postNode) {
         /* @var $postNode NodeInterface */
         $uriBuilder->setFormat('html');
         $postUri = $uriBuilder->uriFor('show', array('node' => $postNode), 'Frontend\\Node', 'TYPO3.Neos');
         $item = new Item();
         $item->setTitle($postNode->getProperty('title'));
         $item->setGuid($postNode->getIdentifier());
         // TODO: Remove this once all old node properties are migrated:
         $publicationDate = $postNode->getProperty('datePublished');
         if (is_string($publicationDate)) {
             $publicationDate = \DateTime::createFromFormat('Y-m-d', $publicationDate);
             $postNode->setProperty('datePublished', $publicationDate);
         }
         $item->setPublicationDate($postNode->getProperty('datePublished'));
         $item->setItemLink((string) $postUri);
         $item->setCommentsLink((string) $postUri . '#comments');
         // TODO: Remove this once all old node properties are migrated:
         $author = $postNode->getProperty('author');
         if ($author === NULL) {
             $author = 'Robert Lemke';
             $postNode->setProperty('author', $author);
         }
         $item->setCreator($author);
         #			$item->setCategories(array('test'));
         $description = $this->contentService->renderTeaser($postNode) . ' <a href="' . $postUri . '">Read more</a>';
         $item->setDescription($description);
         $channel->addItem($item);
     }
     // This won't work yet (plugin sub responses can't set headers yet) but keep that as a reminder:
     $headers = $this->response->getHeaders();
     $headers->setCacheControlDirective('s-max-age', 3600);
     $headers->set('Content-Type', 'application/rss+xml');
     $feed = new Feed();
     $feed->addChannel($channel);
     return $feed->render();
 }
 /**
  * @test
  */
 public function buildDoesNotPrependsScriptRequestPathIfCreateRelativePathsCompatibilityFlagIsTrue()
 {
     $this->mockHttpRequest->expects($this->never())->method('getScriptRequestPath');
     $this->mockRouter->expects($this->once())->method('resolve')->will($this->returnValue('resolvedUri'));
     $this->uriBuilder->setCreateAbsoluteUri(FALSE);
     $this->uriBuilder->setCreateRelativePaths(TRUE);
     $expectedResult = 'resolvedUri';
     $actualResult = $this->uriBuilder->build();
     $this->assertEquals($expectedResult, $actualResult);
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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');
 }