src/AssetManager/Service/AssetFilterManager.php
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);
    }
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);
    }
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 ) ; }
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
Ensure that the filters as filter are set .