/** * Redirect the web flow to the given uri * * @param __Uri|string the uri (or an string representing the uri) to redirect to * @param __IRequest &$request */ public function redirect($uri, __IRequest &$request = null, $redirection_code = null) { if (is_string($uri)) { $uri = __UriFactory::getInstance()->createUri($uri); } else { if (!$uri instanceof __Uri) { throw __ExceptionFactory::getInstance()->createException('Unexpected type for uri parameter: ' . get_class($uri)); } } $url = $uri->getUrl(); $message = new __AsyncMessage(); $message->getHeader()->setLocation($url); $this->getResponse()->addContent($message->toJson()); $client_notificator = __ClientNotificator::getInstance(); //notify to client: $client_notificator->notify(); //clear dirty components to avoid notify again in next requests: $client_notificator->clearDirty(); }
public function displayError(Exception $exception) { if ($exception instanceof __LionException) { $error_title = $exception->getErrorTitle(); } else { $error_title = 'Core Error'; } $error_message = $exception->getMessage(); $error_code = $exception->getCode(); $message = new __AsyncMessage(); $message->getHeader()->setStatus(__AsyncMessageHeader::ASYNC_MESSAGE_STATUS_ERROR); if (__Lion::getInstance()->getRuntimeDirectives()->getDirective('DEBUG_MODE')) { $message->getHeader()->setMessage("{$error_title} ({$error_code}):\n{$error_message}"); } __FrontController::getInstance()->getResponse()->addContent($message->toJson()); __FrontController::getInstance()->getResponse()->flush(); exit; }