コード例 #1
0
ファイル: index.php プロジェクト: geofac/mapguide-rest
$config = array_merge($config, $logConfig);
//Pull in the appropriate string bundle
$strings = (require_once dirname(__FILE__) . "/app/res/lang/" . $config["Locale"] . ".php");
$app = new \Slim\Slim($config);
//Override error handler for unhandled exceptions
$app->error(function ($err) use($app) {
    $title = $app->localizer->getText("E_UNHANDLED_EXCEPTION");
    $mimeType = MgMimeType::Html;
    //As part of validating the desired representation, this variable will be set, this will tell us
    //what mime type to shape the response
    if (isset($app->requestedMimeType)) {
        $mimeType = $app->requestedMimeType;
    }
    $details = $app->localizer->getText("E_PHP_EXCEPTION_DETAILS", $err->getMessage(), $err->getFile(), $err->getLine());
    $app->response->header("Content-Type", $mimeType);
    $app->response->setBody(MgUtils::FormatException($app, "UnhandledError", $title, $details, $err->getTraceAsString(), 500, $mimeType));
});
$app->localizer = new Localizer($strings);
//Set server version
$ver = explode(".", SITE_ADMINISTRATOR_VERSION, 4);
$app->MG_VERSION = array(intval($ver[0]), intval($ver[1]), intval($ver[2]), intval($ver[3]));
$app->config("SelfUrl", $app->request->getUrl() . $app->request->getRootUri());
$un = new URL\Normalizer($app->config("SelfUrl") . "/" . $app->config("MapGuide.MapAgentUrl"));
$app->config("MapGuide.MapAgentUrl", $un->normalize());
/*
var_dump($app->localizer->getText("E_METHOD_NOT_SUPPORTED"));
var_dump($app->localizer->getText("E_METHOD_NOT_SUPPORTED", "test"));
var_dump($app->localizer->getText("E_METHOD_NOT_SUPPORTED", 123));
var_dump($app->localizer->getText("I_DONT_EXIST"));
var_dump($app->localizer->getText("I_DONT_EXIST", "test"));
var_dump($app->localizer->getText("I_DONT_EXIST", 123));
コード例 #2
0
 protected function FormatException($type, $errorMessage, $details, $phpTrace, $status = 500, $mimeType = MgMimeType::Html)
 {
     return MgUtils::FormatException($this->app, $type, $errorMessage, $details, $phpTrace, $status, $mimeType);
 }