本文整理匯總了PHP中Assetic\Asset\AssetInterface::all方法的典型用法代碼示例。如果您正苦於以下問題:PHP AssetInterface::all方法的具體用法?PHP AssetInterface::all怎麽用?PHP AssetInterface::all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Assetic\Asset\AssetInterface
的用法示例。
在下文中一共展示了AssetInterface::all方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: findAssetsInCollection
/**
* Create list all assets
*/
private function findAssetsInCollection(AssetInterface $asset, $collectionName)
{
if ($asset instanceof AssetCollectionInterface) {
foreach ($asset->all() as $subAsset) {
$this->findAssetsInCollection($subAsset, $collectionName);
}
} else {
if (!in_array($asset, $this->collectionAssets[$collectionName])) {
$this->collectionAssets[$collectionName][] = $asset;
}
}
}
示例2: getHash
/**
* Get the sha1 hash of an asset or asset collection
*
* @param AssetInterface $asset
* @param AssetFactory $factory
* @return string
*/
protected function getHash(AssetInterface $asset, AssetFactory $factory)
{
$hash = hash_init('sha1');
if ($asset instanceof AssetCollectionInterface) {
foreach ($asset->all() as $i => $leaf) {
$this->hashAsset($leaf, $hash);
}
} else {
$this->hashAsset($asset, $hash);
}
return substr(hash_final($hash), 0, 7);
}
示例3: 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);
}
示例4: getCompileFileName
/**
* Builds a compile filename for an asset with the
* requested extension.
*
* @param \Assetic\Asset\AssetInterface $asset
* @param string $extension
* @return string
*/
public function getCompileFileName(AssetInterface $asset, $extension)
{
$cacheKey = '';
$assetName = '';
if ($asset instanceof AssetCollectionInterface) {
switch ($extension) {
case 'css':
$assetName = 'styles';
break;
case 'js':
default:
$assetName = 'scripts';
break;
}
foreach ($asset->all() as $actualAsset) {
$cacheKey .= $this->getCacheKey($actualAsset);
}
} else {
$assetName = $asset->getSlug();
$cacheKey .= $this->getCacheKey($asset);
}
if ($values = $asset->getValues()) {
asort($values);
$cacheKey .= serialize($values);
}
$lastModified = $asset->getLastModified();
return $assetName . '.' . md5($cacheKey) . '_' . $lastModified . ".{$extension}";
}