Assetic CacheBustingWorker LazyAssetManager

116 Views Asked by At

This relates to Assetic, and not AsseticBundle.

I am having trouble getting the cache busting worker to actually bust the cache. The below code places a file 'two_regions' in .styles/compiled/assetic/ folder - the cache busting worker however, checks to see if it finds 'two_regions_bundle_a_1' which never got generated, any idea what I am doing wrong?

<?php
require_once('../vendor/autoload.php');

$am = new \Assetic\AssetManager();

$ar = new \Assetic\Asset\FileAsset('../styles/region_a.css');
$at = new \Assetic\Asset\FileAsset('../styles/region_b.css');
$ar->setTargetPath('region_a.css');
$at->setTargetPath('region_b.css');
$am->set('a', $ar);
$am->set('b', $at);

$css_min = new \Assetic\Filter\CssMinFilter();
$fm = new \Assetic\FilterManager();
$fm->set('css_min', $css_min);

$factory =  new \Assetic\Factory\AssetFactory('../styles/compiled/');
$factory->setAssetManager($am);
$factory->setFilterManager($fm);
$factory->addWorker(new \Assetic\Factory\Worker\CacheBustingWorker());

$formula = [
    [
        '@a',
        '@ab'
    ],
    [
        'css_min'
    ]
];

$lazyAm = new \Assetic\Factory\LazyAssetManager($factory);
$lazyAm->setFormula('two_regions', $formula);

$writer = new \Assetic\AssetWriter('./compiled/');
$writer->writeManagerAssets($lazyAm);
0

There are 0 best solutions below