Question

I would like to create my own Assetic filter similar to those LESS, SASS and Google Closure Compiler filters.

I can see that the filters are in vendor/assetic/src/Assetic/Filter, but obviously I can't just modify that codebase.

Was it helpful?

Solution

The right way should be to create a service that encapsulate your business logic inside the DIC and to tag it with the assetic.filter_manager tag.

For example the builtin coffee script filter is registered this way:

<service id="assetic.filter.coffee" class="%assetic.filter.coffee.class%">
    <tag name="assetic.filter" alias="coffee" />
    <argument>%assetic.filter.coffee.bin%</argument>
    <argument>%assetic.filter.coffee.node%</argument>
</service>

Modifying the code base is definitely the wrong way to do something like this, symfony DIC provide much better solutions!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top