本文整理汇总了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}";
}