Exemplo n.º 1
0
 function testExceptionToJson()
 {
     $json = '{' . '"code":420,' . '"status":"exception",' . '"exception":"Core3\\\\Exception\\\\InvalidArgument",' . '"message":"",' . '"file":"' . __FILE__ . '",' . '"line":' . (__LINE__ + 5) . '}';
     $this->assertEquals($json, \Core3\Api\ResponseError::exceptionToJson(new \Core3\Exception\InvalidArgument()));
 }
Exemplo n.º 2
0
        $orgMtime = filemtime($scssFile);
        $cacheMtime = filemtime($cachedFile);
        if ($cacheMtime > $orgMtime) {
            $data = file_get_contents($cachedFile);
        } else {
            // update cache
            $data = $scss->renderViewToCss($viewName);
            $scss->writeCache($cachedFile, $data);
        }
    } else {
        // create initial cached
        $data = $scss->renderViewToCss($viewName);
        $scss->writeCache($cachedFile, $data);
    }
    $etag = '"' . md5($viewName . $scss->getCachedFileMtime($viewName)) . '"';
    header('ETag: ' . $etag);
    $timestamp = filemtime($scss->getCachedFileName($viewName));
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s ', $timestamp) . 'GMT');
    if (isClientCachingDocument($etag)) {
        throw new \Core3\Exception\CachedInClient();
    }
    echo $data;
} catch (\Core3\Exception\CachedInClient $ex) {
    $this->setHttpResponseCode(304);
    // Not Modified
} catch (\Exception $ex) {
    $this->setHttpResponseCode(400);
    // Bad Request
    header('Content-Type: application/json');
    echo \Core3\Api\ResponseError::exceptionToJson($ex);
}