kriswallsmith / assetic

Asset Management for PHP
MIT License
3.75k stars 555 forks source link

assetic:dump discovery of namespaced twig paths #739

Open viktorasp opened 9 years ago

viktorasp commented 9 years ago

Is there a way to hint assetic where to look for templates? Currently we are using namespaced twig paths for some of the templates, however I fail to see how to easily add those to the scanned list. I've tried adding as a 'addResource' in a compiler pass, however when assetic attempt to read file content, it goes to "Bundle:Controller:Name" syntax which is wrong in case of namespaced paths. Am I missing something here or are namespaced paths not supported? And then in general, is it possible to provide hinting to assetic which paths to scan for twig templates?

hcomnetworkers commented 9 years ago

I need a way to hint assetic which templates should be parsed, too. Is there any progress on this issue? Currently, all bundles are scanned for twig templates to be parsed. In production, I don't want the debug templates to be parsed, but I didn't find a way to hint that these templates should not be added. A blacklist / whitelist of paths or bundles would be sufficient for me.

isometriks commented 9 years ago

Create a service for this class: https://github.com/kriswallsmith/assetic/blob/master/src/Assetic/Factory/Resource/DirectoryResource.php

And then in your config file:

<service id="my_custom_resource" class="...\DirectoryResource">
    <argument>%kernel.root_dir%/../some/path</argument>

    <tag name="assetic.formula_resource" loader="twig" />
</service>

Or you can use the CoalescingDirectoryResource to pass multiple directories. But its constructor should be an array of DirectoryResources or some other IteratorResourceInterface, so you would probably want to use a compiler pass there, or do something like this: https://github.com/symedit/ThemeBundle/blob/master/Assetic/Factory/Resource/ThemeTwigResource.php