本文整理汇总了PHP中Slim\Slim::expires方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::expires方法的具体用法?PHP Slim::expires怎么用?PHP Slim::expires使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\Slim
的用法示例。
在下文中一共展示了Slim::expires方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmlOutput
/**
* @param IXmlExporter $exporter
* @param int $status
* @param string $contentType
*/
protected function xmlOutput(IXmlExporter $exporter, $status = 200, $contentType = 'application/xml')
{
$this->app->expires(0);
$this->app->contentType($contentType);
$response = $this->app->response();
$response->setStatus($status);
$response->header('Content-Description', 'File Transfer');
if ($exporter->isFile()) {
$response->header('Content-Disposition', 'attachment; filename=' . $exporter->getFileName());
}
$response->body($exporter->buildXml());
}
示例2: addRouteDefinitions
/**
* This methods will be called at application startup
* @param $appInstance
* @return void
* @throws \Exception
*/
public static function addRouteDefinitions(Slim $appInstance)
{
$appInstance->map('/protected-storage/:inst/:id/:accessMethod/:path+', function ($inst, $id, $accessMethod, $path) use($appInstance) {
if (!in_array($accessMethod, cProtectedStorage::$allowedAccessMethods, true)) {
$appInstance->halt(400, 'Invalid request');
}
$fileName = array_pop($path);
$rel = '';
foreach ($path as $value) {
$rel .= $value . '/';
}
$rel .= $fileName;
$user = null;
if ($accessMethod === 'private') {
try {
$user = new MembersAuth();
$user->isUserLoggedIn();
} catch (LoginExceptions $e) {
$appInstance->halt(401, 'Unauthorized');
}
}
$fullPath = $inst . '/' . $id . '/' . $accessMethod . '/' . $rel;
$controller = new cProtectedStorage($inst, $id, $accessMethod, $rel);
if ($controller->isCorrectPath($fullPath)) {
$appInstance->etag(md5($fullPath));
$appInstance->expires('+1 week');
$headers = $controller->outputFile();
if (array_key_exists('download', $_REQUEST)) {
$headers['Content-Type'] = 'application/octet-stream';
}
foreach ($headers as $key => $value) {
$appInstance->response->headers->set($key, $value);
}
} else {
$appInstance->notFound();
}
})->via('GET', 'POST');
}
示例3: cacheAndAccessHeader
public function cacheAndAccessHeader()
{
$this->_app->response->headers->set('Access-Control-Allow-Origin', '*');
$this->_app->expires(date('D, d M Y H:i:s O', time() + $this->_applicationConfig['cacheDuration']));
}