本文整理汇总了PHP中Assetic\Asset\AssetInterface::ensureFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetInterface::ensureFilter方法的具体用法?PHP AssetInterface::ensureFilter怎么用?PHP AssetInterface::ensureFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Asset\AssetInterface
的用法示例。
在下文中一共展示了AssetInterface::ensureFilter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dump
public function dump(AssetInterface $asset)
{
$writer = new \Assetic\AssetWriter(sys_get_temp_dir(), $this->container->getParameter('assetic.variables'));
$ref = new \ReflectionMethod($writer, 'getCombinations');
$ref->setAccessible(true);
$name = $asset->getSourcePath();
$type = substr($name, strrpos($name, '.') + 1);
switch ($type) {
case 'coffee':
$asset->ensureFilter($this->container->get('assetic.filter.coffee'));
$type = 'js';
break;
case 'less':
$asset->ensureFilter($this->container->get('assetic.filter.less'));
$type = 'css';
break;
}
$combinations = $ref->invoke($writer, $asset->getVars());
$asset->setValues($combinations[0]);
$asset->load();
$content = $asset->getContent();
// because the assetic cssrewrite makes bullshit here, we need to reimplement the filter
if ($type === 'css') {
$content = $this->cssFilter($content, '/' . dirname($asset->getSourcePath()));
}
return $content;
}
示例2: process
public function process(AssetInterface $asset)
{
if (0 < preg_match($this->pattern, $asset->getTargetUrl())) {
$asset->ensureFilter($this->filter);
}
return $asset;
}
示例3: createInnerAsset
private function createInnerAsset()
{
if ($this->innerAsset) {
throw new RuntimeException('The inner asset must be created only once.');
}
$this->innerAsset = $this->factory->parseInputWithFixedValues($this->input, $this->currentDir, $this->roots, $this->vars, $this->values);
foreach ($this->filters as $filter) {
$this->innerAsset->ensureFilter($filter);
}
if (null !== $this->content) {
$this->innerAsset->setContent($this->content);
}
if (null !== $this->targetPath) {
$this->innerAsset->setTargetPath($this->targetPath);
}
// GC
$this->factory = null;
$this->input = null;
$this->currentDir = null;
$this->roots = null;
$this->content = null;
$this->targetPath = null;
}
示例4: applyFilters
private function applyFilters(AssetInterface $asset, $fileType)
{
if ($fileType == 'css') {
$asset->ensureFilter(new CssRewriteFilter());
//NECESSARY FOR IMAGE PATHS
}
}
示例5: process
public function process(AssetInterface $asset, AssetFactory $factory)
{
if (self::CHECK_SOURCE === (self::CHECK_SOURCE & $this->flags) && preg_match($this->pattern, $asset->getSourcePath()) || self::CHECK_TARGET === (self::CHECK_TARGET & $this->flags) && preg_match($this->pattern, $asset->getTargetPath())) {
$asset->ensureFilter($this->filter);
}
}
示例6: ensureByFilter
/**
* Ensure that the filters as filter are set.
*
* @param AssetInterface $asset
* @param mixed $filter Either an instance of FilterInterface or a classname.
* @throws Exception\RuntimeException
*/
protected function ensureByFilter(AssetInterface $asset, $filter)
{
if ($filter instanceof FilterInterface) {
$filterInstance = $filter;
$asset->ensureFilter($filterInstance);
return;
}
$filterClass = $filter;
if (!is_subclass_of($filterClass, 'Assetic\\Filter\\FilterInterface', true)) {
$filterClass .= substr($filterClass, -6) === 'Filter' ? '' : 'Filter';
$filterClass = 'Assetic\\Filter\\' . $filterClass;
}
if (!class_exists($filterClass)) {
throw new Exception\RuntimeException('No filter found for ' . $filter);
}
if (!isset($this->filterInstances[$filterClass])) {
$this->filterInstances[$filterClass] = new $filterClass();
}
$filterInstance = $this->filterInstances[$filterClass];
$asset->ensureFilter($filterInstance);
}
示例7: ensureFilter
/**
* Ensures the current asset includes the supplied filter.
*
* @param FilterInterface $filter
*/
public function ensureFilter(FilterInterface $filter)
{
$this->asset->ensureFilter($filter);
}
示例8: 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);
}
}
}
示例9: process
/**
* Processes an asset.
*
* @param AssetInterface $asset An asset
* @param Boolean $debug Debug mode
*/
public function process(AssetInterface $asset, $debug = false)
{
if ((null === $this->debug || $this->debug === $debug) && preg_match($this->pattern, $asset->getTargetUrl())) {
$asset->ensureFilter($this->filter);
}
}