本文整理汇总了PHP中Assetic\Asset\AssetInterface::getFilters方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetInterface::getFilters方法的具体用法?PHP AssetInterface::getFilters怎么用?PHP AssetInterface::getFilters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Asset\AssetInterface
的用法示例。
在下文中一共展示了AssetInterface::getFilters方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFilters
/**
* {@inheritdoc}
*/
public function getFilters()
{
if ($this->innerAsset) {
return $this->innerAsset->getFilters();
}
return $this->filters->all();
}
示例2: 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);
}
示例3: 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;
}
示例4: getCacheKey
/**
* Returns the cache key for the given filters of an asset.
*
* @param \Assetic\Asset\AssetInterface $asset
* @return string $cacheKey
* @throws \InvalidArgumentException
*/
public function getCacheKey(AssetInterface $asset)
{
if ($asset instanceof AssetCollectionInterface) {
throw new InvalidArgumentException('getCacheKey() should only be called on individual assets.');
}
$cacheKey = $asset->getSourceRoot();
$cacheKey .= $asset->getSourcePath();
$cacheKey .= $asset->getTargetPath();
foreach ($asset->getFilters() as $filter) {
if ($filter instanceof HashableInterface) {
$cacheKey .= $filter->hash();
} else {
$cacheKey .= serialize($filter);
}
}
return $cacheKey;
}
示例5: getFilters
/**
* Returns an array of filters currently applied.
*
* @return array
*/
public function getFilters()
{
return $this->asset->getFilters();
}
示例6: cleanFilters
/**
* Clean filters, remove css-rewrite filter and inherit collection filters.
*
* @param AssetInterface $asset The asset.
* @param array $inheritedFilters The inherited filters.
*
* @return void
*/
private function cleanFilters(AssetInterface $asset, array $inheritedFilters)
{
// remove css-rewrite filter
$filters = $asset->getFilters();
$asset->clearFilters();
foreach ($filters as $filter) {
if (!$filter instanceof CssRewriteFilter) {
$asset->ensureFilter($filter);
}
}
// inherit filters
foreach ($inheritedFilters as $filter) {
if (!$filter instanceof CssRewriteFilter) {
$asset->ensureFilter($filter);
}
}
}