當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。