本文整理匯總了PHP中DateTimeHelper::isValidIntervalString方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTimeHelper::isValidIntervalString方法的具體用法?PHP DateTimeHelper::isValidIntervalString怎麽用?PHP DateTimeHelper::isValidIntervalString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DateTimeHelper
的用法示例。
在下文中一共展示了DateTimeHelper::isValidIntervalString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getUrlAppendix
/**
* Get appendix for an URL based on it's Source caching settings.
*
* @param BaseAssetSourceType $source
* @param AssetFileModel $file
*
* @return string
*/
public static function getUrlAppendix(BaseAssetSourceType $source, AssetFileModel $file)
{
$appendix = '';
if (!empty($source->getSettings()->expires) && DateTimeHelper::isValidIntervalString($source->getSettings()->expires)) {
$appendix = '?mtime=' . $file->dateModified->format("YmdHis");
}
return $appendix;
}
示例2: putObject
/**
* Put an object into an S3 bucket.
*
* @param $filePath
* @param $bucket
* @param $uriPath
* @param $permissions
*
* @return bool
*/
protected function putObject($filePath, $bucket, $uriPath, $permissions)
{
$object = empty($filePath) ? '' : array('file' => $filePath);
$headers = array();
if (!empty($object) && !empty($this->getSettings()->expires) && DateTimeHelper::isValidIntervalString($this->getSettings()->expires)) {
$expires = new DateTime();
$now = new DateTime();
$expires->modify('+' . $this->getSettings()->expires);
$diff = $expires->format('U') - $now->format('U');
$headers['Cache-Control'] = 'max-age=' . $diff . ', must-revalidate';
}
return $this->_s3->putObject($object, $bucket, $uriPath, $permissions, array(), $headers);
}