本文整理汇总了PHP中Assetic\Factory\AssetFactory::getLastModified方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetFactory::getLastModified方法的具体用法?PHP AssetFactory::getLastModified怎么用?PHP AssetFactory::getLastModified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Factory\AssetFactory
的用法示例。
在下文中一共展示了AssetFactory::getLastModified方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process(AssetInterface $asset, AssetFactory $factory)
{
$path = $asset->getTargetPath();
$ext = pathinfo($path, PATHINFO_EXTENSION);
$lastModified = $factory->getLastModified($asset);
if (null !== $lastModified) {
$path = substr_replace($path, "{$lastModified}.{$ext}", -1 * strlen($ext));
$asset->setTargetPath($path);
}
}
示例2: getHash
protected function getHash(AssetInterface $asset, AssetFactory $factory)
{
$hash = hash_init('sha1');
hash_update($hash, $factory->getLastModified($asset));
if ($asset instanceof AssetCollectionInterface) {
foreach ($asset as $i => $leaf) {
$sourcePath = $leaf->getSourcePath();
hash_update($hash, $sourcePath ?: $i);
}
}
return substr(hash_final($hash), 0, 7);
}
示例3: prepareRequest
/**
* Combines asset file references of a single type to produce
* a URL reference to the combined contents.
* @param array $assets List of asset files.
* @param string $localPath File extension, used for aesthetic purposes only.
* @return string URL to contents.
*/
protected function prepareRequest(array $assets, $localPath = null)
{
if (substr($localPath, -1) != '/') {
$localPath = $localPath . '/';
}
$this->localPath = $localPath;
$this->storagePath = storage_path('cms/combiner/assets');
list($assets, $extension) = $this->prepareAssets($assets);
/*
* Cache and process
*/
$cacheKey = $this->getCacheKey($assets);
$cacheInfo = $this->useCache ? $this->getCache($cacheKey) : false;
if (!$cacheInfo) {
$this->setHashOnCombinerFilters($cacheKey);
$combiner = $this->prepareCombiner($assets);
if ($this->useDeepHashing) {
$factory = new AssetFactory($this->localPath);
$lastMod = $factory->getLastModified($combiner);
} else {
$lastMod = $combiner->getLastModified();
}
$cacheInfo = ['version' => $cacheKey . '-' . $lastMod, 'etag' => $cacheKey, 'lastMod' => $lastMod, 'files' => $assets, 'path' => $this->localPath, 'extension' => $extension];
$this->putCache($cacheKey, $cacheInfo);
}
return $this->getCombinedUrl($cacheInfo['version']);
}
示例4: writeAssets
/**
* Write collection in web folder
*
* @param Assetic\Factory\AssetFactory $assetFactory
* @param string $file
*/
protected function writeAssets($assetFactory, $file, $web, $tragetFile)
{
if (true === $this->lastModifedHandler($assetFactory->getLastModified(), $file, $web . $tragetFile)) {
$writer = new AssetWriter($web);
$writer->writeAsset($assetFactory);
}
}