public static function onRouteNotFound(BaseEvent $event) { if (!DC::getRouter()->getCurrentRequest()->isXHR()) { DC::getRouter()->redirectToRelativeUri('admin/'); } else { $response = new Response(); $response->setStatusCode(HttpStatus::HTTP_NOT_FOUND); $response->send(); } }
public function redirectToUri($relativeUri) { $request = DC::getRouter()->getCurrentRequest(); if ($relativeUri == '/') { $relativeUri = ''; } $webRoot = DC::getRouter()->getWebRoot(); $applicationUrlPart = ($webRoot !== "/" ? $webRoot . '/' : '') . (DC::getApplication()->getName() == 'frontend' ? '' : DC::getApplication()->getName() . '/'); $fullUrl = $request->getHost() . '/' . $applicationUrlPart . $relativeUri; $fullUrl = str_replace('//', '/', $fullUrl); $response = new Response(); $response->setStatusCode(HttpStatus::HTTP_FOUND); $response->setHeader('Location', $request->getProtocol() . '://' . $fullUrl); if (headers_sent()) { DC::getLogger()->add('Cannot redirect to ' . $relativeUri); } $response->send(); die; }
public function render($templateName = null) { if ($this->_alreadyRendered) { return true; } $vars = $this->getCombinedVars(); if ($this->_responseFormat == View::FORMAT_HTML) { if (empty($templateName)) { if (empty($this->_templateName)) { $this->detectTemplate(); } $templateName = $this->_templateName; } if ($layout = $this->getLayoutTemplate()) { $vars['innerTemplateContent'] = $this->fetchTemplate($templateName, $vars); $templateName = $layout; } } $this->_response->setContent($this->fetchTemplate($templateName, $vars)); $this->_response->send(); $this->_alreadyRendered = true; }
public function tmpFileAction() { if ($path = $this->request->getVar('p')) { if (!FSService::showFileAndExit(DC::getEnvironment()->getTmpRoot() . $path)) { $response = new Response('<h1>Requested content not found</h1>', 404); $response->send(); die; } } }
public function redirectToRelativeUri($relativeUri) { if ($relativeUri == '/') { $relativeUri = ''; } $fullUrl = $this->getBaseUri() . $relativeUri; $response = new Response(); $response->setStatusCode(HttpStatus::HTTP_FOUND); $response->setHeader('Location', $fullUrl); $response->send(); die; }