-
Notifications
You must be signed in to change notification settings - Fork 82
Filters
Filters can be very important. When using lesscss, large unminified javascript libraries like jquery or even just collections of unminified javascript code you wrote you might want to apply filters before outputting, or caching filters. Making use of assetic you already have access to a lot of standard filters.
Filtering assets has a lot of benefits. It allows you to minify code, optimize images, use dynamic stylesheet languages, use stuff like coffeescript and so on. AssetManager applies the filters to specific assets. This can be useful, especially when combining assets in asset collections. Note: It's currently not possible to apply filters to extensions or mime types. This will be added in the future.
Applying filters is pretty straight forward. You use the same method that's used when applying caching. Enough talking, here's an example:
<?php
return array(
'asset_manager' => array(
'filters' => array(
'js/myAsset.js' => array(
array(
// Note: You will need to require the classes used for the filters yourself.
'filter' => 'JSMin', // Allowed format is Filtername[Filter]. Can also be FQCN
),
),
),
),
);There's not much to it. This is all there is to it. You can build your own filters implementing the Assetic\Filter\FilterInterface interface, but I don't think it'll come to that because of the large amount of filters already supplied by assetic.