当前位置: 首页>>代码示例>>PHP>>正文


PHP SimpleSAML_Utilities::parseDuration方法代码示例

本文整理汇总了PHP中SimpleSAML_Utilities::parseDuration方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_Utilities::parseDuration方法的具体用法?PHP SimpleSAML_Utilities::parseDuration怎么用?PHP SimpleSAML_Utilities::parseDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleSAML_Utilities的用法示例。


在下文中一共展示了SimpleSAML_Utilities::parseDuration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getExpireTime

 /**
  * Determine how long a given element can be cached.
  *
  * This function looks for the 'cacheDuration' and 'validUntil' attributes to determine
  * how long a given XML-element is valid. It returns this as na unix timestamp.
  *
  * If both the 'cacheDuration' and 'validUntil' attributes are present, the shorter of them
  * will be returned.
  *
  * @param DOMElement $element  The element we should determine the expiry time of.
  * @return int  The unix timestamp for when the element should expire. Will be NULL if no
  *              limit is set for the element.
  */
 private static function getExpireTime(DOMElement $element)
 {
     if ($element->hasAttribute('cacheDuration')) {
         $cacheDuration = $element->getAttribute('cacheDuration');
         $cacheDuration = SimpleSAML_Utilities::parseDuration($cacheDuration, time());
     } else {
         $cacheDuration = NULL;
     }
     if ($element->hasAttribute('validUntil')) {
         $validUntil = $element->getAttribute('validUntil');
         $validUntil = SimpleSAML_Utilities::parseSAML2Time($validUntil);
     } else {
         $validUntil = NULL;
     }
     if ($cacheDuration !== NULL && $validUntil !== NULL) {
         /* Both are given. Return the shortest. */
         if ($cacheDuration < $validUntil) {
             return $cacheDuration;
         } else {
             return $validUntil;
         }
     } elseif ($cacheDuration !== NULL) {
         return $cacheDuration;
     } elseif ($validUntil !== NULL) {
         return $validUntil;
     } else {
         return NULL;
     }
 }
开发者ID:hukumonline,项目名称:yii,代码行数:42,代码来源:SAMLParser.php

示例2: getExpireTime

 /**
  * Determine how long a given element can be cached.
  *
  * This function looks for the 'cacheDuration' and 'validUntil' attributes to determine
  * how long a given XML-element is valid. It returns this as na unix timestamp.
  *
  * If both the 'cacheDuration' and 'validUntil' attributes are present, the shorter of them
  * will be returned.
  *
  * @param mixed $element  The element we should determine the expiry time of.
  * @param int|NULL $maxExpireTime  The maximum expiration time.
  * @return int  The unix timestamp for when the element should expire. Will be NULL if no
  *              limit is set for the element.
  */
 private static function getExpireTime($element, $maxExpireTime)
 {
     if ($element->cacheDuration !== NULL) {
         $expire = SimpleSAML_Utilities::parseDuration($element->cacheDuration, time());
         if ($maxExpireTime !== NULL && $maxExpireTime < $expire) {
             $expire = $maxExpireTime;
         }
     } else {
         $expire = $maxExpireTime;
     }
     if ($element->validUntil !== NULL) {
         if ($expire === NULL || $expire > $element->validUntil) {
             $expire = $element->validUntil;
         }
     }
     return $expire;
 }
开发者ID:WebSpider,项目名称:OpenConext-guestidp,代码行数:31,代码来源:SAMLParser.php

示例3: updateCache

 /**
  * Attempt to update our cache file.
  */
 public function updateCache()
 {
     if ($this->updateAttempted) {
         return;
     }
     $this->updateAttempted = TRUE;
     $this->metadata = $this->downloadMetadata();
     if ($this->metadata === NULL) {
         return;
     }
     $expires = time() + 24 * 60 * 60;
     /* Default expires in one day. */
     if ($this->metadata->validUntil !== NULL && $this->metadata->validUntil < $expires) {
         $expires = $this->metadata->validUntil;
     }
     if ($this->metadata->cacheDuration !== NULL) {
         try {
             $durationTo = SimpleSAML_Utilities::parseDuration($this->metadata->cacheDuration);
         } catch (Exception $e) {
             SimpleSAML_Logger::warning($this->logLoc . 'Invalid cacheDuration in metadata from ' . var_export($this->url, TRUE) . ': ' . var_export($this->metadata->cacheDuration, TRUE));
             return;
         }
         if ($durationTo < $expires) {
             $expires = $durationTo;
         }
     }
     $metadataSerialized = serialize($this->metadata);
     $this->aggregator->addCacheItem($this->cacheId, $metadataSerialized, $expires, $this->cacheTag);
 }
开发者ID:filonuse,项目名称:fedlab,代码行数:32,代码来源:EntitySource.php


注:本文中的SimpleSAML_Utilities::parseDuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。