How to create own Symfony Assetic Filters?
문제
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.
해결책
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!
제휴하지 않습니다 StackOverflow