/** * Get the default authorization failed callback function */ public function authFailedHandler() { $this->contentType($this->config("content-type")); $data = Serializer::getSerializedData($this, array("message" => "You are not authorized to execute this function")); $this->halt(Status::UNAUTHORIZED, $data); }
/** * If a @template annotation has been defined, this function will return the output * of Slim's parsing of a template, if the correct @render annotation has been specified * * @param Route $autoroute * @param \Spore\Spore $app * @param $data * * @return string */ private function getTemplateOutput(Route $autoroute, Spore $app, $data) { $template = $autoroute->getTemplate(); $renderMode = $autoroute->getRender(); $output = ""; switch ($renderMode) { case "always": $app->render($template, $data); $output = ob_get_clean(); break; case "never": return Serializer::getSerializedData($app, $data); break; default: if (!$app->request()->isAjax()) { $app->render($template, $data); $output = ob_get_clean(); } else { return Serializer::getSerializedData($app, $data); } break; } return $output; }