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


PHP AssetInterface::getLastModified方法代码示例

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


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

示例1: process

 public function process(AssetInterface $asset)
 {
     $hash = hash_init('sha1');
     switch ($this->strategy) {
         case self::STRATEGY_MODIFICATION:
             hash_update($hash, $asset->getLastModified());
             break;
         case self::STRATEGY_CONTENT:
             hash_update($hash, $asset->dump());
             break;
     }
     foreach ($asset as $i => $leaf) {
         if ($sourcePath = $leaf->getSourcePath()) {
             hash_update($hash, $sourcePath);
         } else {
             hash_update($hash, $i);
         }
     }
     $hash = substr(hash_final($hash), 0, 7);
     $url = $asset->getTargetPath();
     $oldExt = pathinfo($url, PATHINFO_EXTENSION);
     $newExt = '-' . $hash . '.' . $oldExt;
     if (!$oldExt || 0 < preg_match('/' . preg_quote($newExt, '/') . '$/', $url)) {
         return;
     }
     $asset->setTargetPath(substr($url, 0, (strlen($oldExt) + 1) * -1) . $newExt);
 }
开发者ID:alexBLR,项目名称:firmware,代码行数:27,代码来源:CacheBustingWorker.php

示例2: __construct

 /**
  * @param AssetInterface $asset
  * @param AssetWriter $writer
  * @param array $cachePath
  * @param array $headers
  */
 public function __construct(AssetInterface $asset, AssetWriter $writer, $cachePath, array $headers = [])
 {
     $file = $asset->getTargetPath();
     $cachePath = $cachePath . '/' . $file;
     $cached = false;
     $cacheTime = time();
     if (is_file($cachePath)) {
         $mTime = $asset->getLastModified();
         $cacheTime = filemtime($cachePath);
         if ($mTime > $cacheTime) {
             @unlink($cachePath);
             $cacheTime = $mTime;
         } else {
             $cached = true;
         }
     }
     if (!$cached) {
         $writer->writeAsset($asset);
     }
     $stream = function () use($cachePath) {
         readfile($cachePath);
     };
     $headers['Content-Length'] = filesize($cachePath);
     if (preg_match('/.+\\.([a-zA-Z0-9]+)/', $file, $matches)) {
         $ext = $matches[1];
         if (isset($this->mimeTypes[$ext])) {
             $headers['Content-Type'] = $this->mimeTypes[$ext];
         }
     }
     parent::__construct($stream, 200, $headers);
     $date = new \DateTime();
     $date->setTimestamp($cacheTime);
     $this->setLastModified($date);
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:40,代码来源:AssetResponse.php

示例3: getLastModified

 /**
  * {@inheritdoc}
  */
 public function getLastModified()
 {
     if (!$this->innerAsset) {
         $this->createInnerAsset();
     }
     return $this->innerAsset->getLastModified();
 }
开发者ID:puli,项目名称:assetic-extension,代码行数:10,代码来源:LazyAsset.php

示例4: writeAsset

 public function writeAsset(AssetInterface $asset)
 {
     foreach (VarUtils::getCombinations($asset->getVars(), $this->values) as $combination) {
         $asset->setValues($combination);
         $path = $this->dir . '/' . VarUtils::resolve($asset->getTargetPath(), $asset->getVars(), $asset->getValues());
         if (!is_dir($path) && (!file_exists($path) || filemtime($path) <= $asset->getLastModified())) {
             static::write($path, $asset->dump());
         }
     }
 }
开发者ID:mohamedsharaf,项目名称:laravel-assetic,代码行数:10,代码来源:CheckedAssetWriter.php

示例5: process

 public function process(AssetInterface $asset, AssetFactory $factory)
 {
     $path = $asset->getTargetPath();
     $ext = pathinfo($path, PATHINFO_EXTENSION);
     $lastModified = $asset->getLastModified();
     if (null !== $lastModified) {
         $path = substr_replace($path, "{$lastModified}.{$ext}", -1 * strlen($ext));
         $asset->setTargetPath($path);
     }
 }
开发者ID:kersten,项目名称:zf2-assetic-module,代码行数:10,代码来源:LastModifiedStrategy.php

示例6: helper

 /**
  * @param AssetInterface $asset
  * @param array $options
  * @return string
  */
 protected function helper(AssetInterface $asset, array $options = array())
 {
     $path = $this->baseUrl . $this->basePath . $asset->getTargetPath();
     $extension = pathinfo($path, PATHINFO_EXTENSION);
     $extension = strtolower($extension);
     if (isset($options['addFileMTime']) && $options['addFileMTime']) {
         $path .= '?' . $asset->getLastModified();
     }
     switch ($extension) {
         case 'js':
             return $this->getScriptTag($path, $options);
         case 'css':
             return $this->getStylesheetTag($path, $options);
     }
     return '';
 }
开发者ID:kersten,项目名称:zf2-assetic-module,代码行数:21,代码来源:Asset.php

示例7: dumpAsset

 private function dumpAsset(AssetInterface $asset)
 {
     // HTTP caching
     $mtime = gmdate('D, d M y H:i:s', $asset->getLastModified()) . 'GMT';
     if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && ($mtime = $_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
         header('HTTP/1.1 304 Not Modified');
         exit;
     }
     // set headers & dump asset
     $extension = pathinfo($asset->getTargetPath(), PATHINFO_EXTENSION);
     if (array_key_exists($extension, self::$extensionsToMimeTypes)) {
         $mimeType = self::$extensionsToMimeTypes[$extension];
         header("Content-Type: {$mimeType}");
         header("Last-Modified: {$mtime}");
         header('Cache-Control: public');
     }
     echo $asset->dump();
     exit;
 }
开发者ID:tripomatic,项目名称:nette-assetic,代码行数:19,代码来源:AssetRoute.php

示例8: getCacheKey

 /**
  * @param AssetInterface $asset
  * @return string 
  */
 protected function getCacheKey(AssetInterface $asset)
 {
     $cacheKey = '';
     if ($asset instanceof AssetCollectionInterface) {
         foreach ($asset->all() as $childAsset) {
             $cacheKey .= $childAsset->getSourcePath();
             $cacheKey .= $childAsset->getLastModified();
         }
     } else {
         $cacheKey .= $asset->getSourcePath();
         $cacheKey .= $asset->getLastModified();
     }
     foreach ($asset->getFilters() as $filter) {
         if ($filter instanceof HashableInterface) {
             $cacheKey .= $filter->hash();
         } else {
             $cacheKey .= serialize($filter);
         }
     }
     return md5($cacheKey);
 }
开发者ID:mpoiriert,项目名称:nucleus,代码行数:25,代码来源:Manager.php

示例9: setupAsset

 public function setupAsset(AssetInterface $asset)
 {
     $path = $this->getBaseUrl() . $asset->getTargetPath();
     return $this->helper($path, $asset->getLastModified());
 }
开发者ID:nuxwin,项目名称:zf2-assetic-module,代码行数:5,代码来源:ViewHelperStrategy.php

示例10: getLastModified

 public function getLastModified(AssetInterface $asset)
 {
     $mtime = $asset->getLastModified();
     if (!($filters = $asset->getFilters())) {
         return $mtime;
     }
     // prepare load path
     $sourceRoot = $asset->getSourceRoot();
     $sourcePath = $asset->getSourcePath();
     $loadPath = $sourceRoot && $sourcePath ? dirname($sourceRoot . '/' . $sourcePath) : null;
     $prevFilters = array();
     foreach ($filters as $filter) {
         $prevFilters[] = $filter;
         if (!$filter instanceof DependencyExtractorInterface) {
             continue;
         }
         // extract children from asset after running all preceeding filters
         $clone = clone $asset;
         $clone->clearFilters();
         foreach (array_slice($prevFilters, 0, -1) as $prevFilter) {
             $clone->ensureFilter($prevFilter);
         }
         $clone->load();
         foreach ($filter->getChildren($this->factory, $clone->getContent(), $loadPath) as $child) {
             $mtime = max($mtime, $this->getLastModified($child));
         }
     }
     return $mtime;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:29,代码来源:LazyAssetManager.php

示例11: getLastModified

 /**
  * Returns the time the current asset was last modified.
  *
  * @return integer|null A UNIX timestamp
  */
 public function getLastModified()
 {
     return $this->asset->getLastModified();
 }
开发者ID:sunnyct,项目名称:silexcmf-assetic,代码行数:9,代码来源:AssetCache.php

示例12: is_stale

 protected function is_stale(AssetInterface $asset)
 {
     $stale = TRUE;
     $target = $asset->getTargetPath();
     if (file_exists($target)) {
         $last = filemtime($target);
         $mod = $asset->getLastModified();
         if ($mod && $last >= $mod) {
             $stale = FALSE;
         }
     }
     return $stale;
 }
开发者ID:dustingraham,项目名称:asset-manager,代码行数:13,代码来源:AssetCompiler.php


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