src/Lokos/ShopBundle/Assetic/Filter/RewriteFilter.php
/**
     * Filters an asset just before it's dumped.
     *
     * @param AssetInterface $asset An asset
     */
Filters an asset just before it's dumped.
@param AssetInterface $asset An asset
Filters an asset just before it ' s dumped . @param AssetInterface $asset An asset
public function filterDump(AssetInterface $asset)
    {
        $targetPath = '/bundles/lokosshop';
        $content = $this->filterReferences(
            $asset->getContent(),
            function ($matches) use ($targetPath) {
                $url = $matches['url'];
                if (strpos($url, 'http') === 0) {
                    return 'url("'.$url.'")';
                }
                if (strpos($url, '../') === 0 && (strpos($url, '/images/') !== false)) {
                    $path = $targetPath.substr($url, strpos($url, '/images/'));
                    return str_replace($url, $path, $matches[0]);
                }
                if (strpos($url, '../') === 0 && (strpos($url, '/fonts/') !== false)) {
                    $path = $targetPath.substr($url, strpos($url, '/fonts/'));
                    return str_replace($url, $path, $matches[0]);
                }
                return $url;
            }
        );
        $asset->setContent($content);
    }
public function filterDump ( AssetInterface $ asset ) { $ targetPath = '/bundles/lokosshop' ; $ content = $ this -> filterReferences ( $ asset -> getContent ( ) , function ( $ matches ) use ( $ targetPath ) { $ url = $ matches [ 'url' ] ; if ( strpos ( $ url , 'http' ) === 0 ) { return 'url("' . $ url . '")' ; } if ( strpos ( $ url , '../' ) === 0 && ( strpos ( $ url , '/images/' ) !== false ) ) { $ path = $ targetPath . substr ( $ url , strpos ( $ url , '/images/' ) ) ; return str_replace ( $ url , $ path , $ matches [ 0 ] ) ; } if ( strpos ( $ url , '../' ) === 0 && ( strpos ( $ url , '/fonts/' ) !== false ) ) { $ path = $ targetPath . substr ( $ url , strpos ( $ url , '/fonts/' ) ) ; return str_replace ( $ url , $ path , $ matches [ 0 ] ) ; } return $ url ; } ) ; $ asset -> setContent ( $ content ) ; }
Filters an asset just before it's dumped.
Filters an asset just before it ' s dumped .