예제 #1
0
 /**
  * @see \Ableron\Core\Template\Plugins\Interfaces\CompilerPluginInterface::compileOpeningTag()
  */
 public function compileOpeningTag(TemplateCompiler $templateCompiler)
 {
     return sprintf('%s/%s', EnvironmentUtil::getBaseUrl()->toString(), ltrim($this->getArgument('url'), '/'));
 }
예제 #2
0
 /**
  * Sends a redirect to the client.
  *
  * In case a relative URI is given, it will be resolved using the current base URI.
  *
  * @param \Ableron\Lib\Net\Uri $redirectUri The URI to redirect to
  * @param int|null $statusCode Status code of the redirect, e.g. relevant for HTTP redirects
  * @return void
  */
 public function sendRedirect(Uri $redirectUri, $statusCode = HttpResponse::STATUS_SEE_OTHER)
 {
     // because it is not possible to guess an absolute URL from a relative one because of the flexible module paths, relative URLs are not allowed
     if (!$redirectUri->isAbsolute()) {
         // log error
         Application::getLogManager()->error(sprintf('Unable to perform redirect: Redirect URL must be absolute. Relative URL given: %s', $redirectUri->toString()));
         // redirect to base URL
         $redirectUri = EnvironmentUtil::getBaseUrl();
     }
     // set response
     $this->setResponse(new HttpResponse($statusCode, null, '', null, array(new LocationHeaderField($redirectUri))));
 }