Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assetic:dump does not scan all themes #25

Closed
pentatonicfunk opened this issue Jan 12, 2012 · 24 comments · Fixed by #118
Closed

assetic:dump does not scan all themes #25

pentatonicfunk opened this issue Jan 12, 2012 · 24 comments · Fixed by #118

Comments

@pentatonicfunk
Copy link

so i have configured my config :
liip_theme:
themes: ['AAA', 'BBB']
active_theme : 'BBB'

and i executed :
./app/console cache:clear --env=local
./app/console assetic:dump --env=local

but the dump just scan for BBB theme dir only
And AAA not scanned

i want the theme is dynamic, so the assetic:dump must scan all themes dir

@stof
Copy link
Contributor

stof commented Jan 12, 2012

are you using the latest version of the bundle ? there should be an assetic integration now

@pentatonicfunk
Copy link
Author

yes i did pull git the assetic bundle and liipTheme bundle

@lsmith77
Copy link
Contributor

did you configure the bundle in question in the assetic configuration?

@pentatonicfunk
Copy link
Author

i did...
assetic
bundle:["MYBUNDLE"]

@lsmith77
Copy link
Contributor

can you search for the getAssetic_AssetManagerService() method in your cached container in the cache dir and see what is generated? should help you debug the issue. thx.

@lsmith77
Copy link
Contributor

ping?

@pentatonicfunk
Copy link
Author

ok. sorry....
in debug it's show all my bundle but the assetic:dump just "dump" my active_theme only

@lsmith77
Copy link
Contributor

hmm i cannot reproduce the issue locally. the relevant class is TemplateResourcesPass:
https://github.com/liip/LiipThemeBundle/blob/master/DependencyInjection/Compiler/TemplateResourcesPass.php

as you can see i am using the parameter to determine the list of themes to iterate over.

@gimler
Copy link
Contributor

gimler commented Feb 9, 2012

i can confirm this problem in the generated cache file all paths are loaded as Resource.

You can test this when you create a layout file with a asset and a theme with the same file with another asset. Now it generate only routes or assets (assetic:dump) for the default theme (Resource/view), but not for all themes.

After some debugging i think the problem is that the TemplateLocator does not know where the resource template file is it gets lost in the FileResource.

/path/to/vendor/bundles/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php

has two properties path and bundle

string(116) "/path/to/vendor/bundles/Gf/MyBundle/Resources/themes/phone/layout_mo.html.twig"
string(16) "GfMyBundle"

getTamplate() gives createTemplateReference()

string(16) "GfMyBundle"
string(19) "layout_mo.html.twig"

so createTemplateReference() create the following TemplateReference

object(Symfony\Bundle\FrameworkBundle\Templating\TemplateReference)#389 (1) {
  ["parameters":protected]=>
  array(5) {
    ["bundle"]=>
    string(16) "GfMyBundle"
    ["controller"]=>
    string(0) ""
    ["name"]=>
    string(9) "layout_mo"
    ["format"]=>
    string(4) "html"
    ["engine"]=>
    string(4) "twig"
  }
}

@lsmith77
Copy link
Contributor

so this is a limitation in assetic bundle?

@wwwdata
Copy link

wwwdata commented Jul 2, 2012

Hi,

I can confirm this problem with the newest version of the master branch too. What is the status? Is somebody working on it atm?

@lsmith77
Copy link
Contributor

lsmith77 commented Jul 2, 2012

not that i am aware of anyone working on this :(

@lsmith77
Copy link
Contributor

ping

@tyx
Copy link

tyx commented May 28, 2013

Hello,

I have the same kind of problem.

Our themes come from database, so when TemplateResourcesPass is called, liip_theme.themes is empty.

So no loop, and therefore no DirectoryResourceDefinition created.

Is there any reason to add specific path for each theme ?

By removing the loop, and add directly the code below, everything work.

           $resources[] = new DirectoryResourceDefinition(
                $bundleName,
                $engine,
                array(
                    $container->getParameter('kernel.root_dir').'/Resources/'.$bundleName.'/themes/',
                    $bundleDirName.'/Resources/themes/',
                )
            );

From my mind, it would resolve all this kind of problem, no ?

@yellow1912
Copy link

I think I get this as well, maybe there should be a work around? Also, @tyx your suggestion will create a problem because not all themes are active I think.

@wachterjohannes
Copy link

i have the same problem now! in sulu we use all themes together and decide with the url which theme is active! but for assetic only one theme is active and crawled! This causes lots of problems ... are there a fix for this issue?

/cc @chirimoya

@ghost
Copy link

ghost commented Dec 23, 2014

Same problem here - Issue #110.

The theme could be added after TemplateResourcesPass is called, liip_theme.themes is empty and will be set later over eventlisteners or any other way. We need an easy solution - what could we do?

@DZunke
Copy link

DZunke commented Jan 26, 2015

after having this problem i found a workaround. i had to move my themes to the "views"-folder and changed the configuration to use these folders. now assetic is loading all theme-styles.

# src/Acme/LayoutBundle/Resources/views/themes/default/layout.html.twig
# src/Acme/LayoutBundle/Resources/views/themes/mobile/layout.html.twig
# src/Acme/LayoutBundle/Resources/views/themes/tablet/layout.html.twig

#
liip_theme:
    themes: ['default', 'tablet', 'mobile']
    active_theme: 'default'
    load_controllers: false
    path_patterns:
        app_resource:
            - %%app_path%%/views/themes/%%current_theme%%/%%template%%
            - %%app_path%%/views/%%template%%
        bundle_resource:
            - %%bundle_path%%/Resources/views/themes/%%current_theme%%/%%template%%
        bundle_resource_dir:
            - %%dir%%/views/themes/%%current_theme%%/%%bundle_name%%/%%template%%
            - %%dir%%/views/%%bundle_name%%/%%override_path%%

before these changes only the last theme "mobile" was rendered - the others were ignored.

@dantleech
Copy link
Contributor

Created a PR which seems to fix this: #118

@dbu
Copy link
Member

dbu commented Mar 24, 2015

#118 is merged. can we close this issue now?

@alexander-schranz
Copy link
Contributor

I did test the assetic:dump on master branch and it seems not to be fixed, I quickly added two new themes with assets but only the active theme was generated also I needed to remove the cache manually(rm app/cache/*) with app/console cache:clear the active theme was not deleted from cache.

the config:

liip_theme:
    themes: ["default", "testtheme", "testtheme2"]
    active_theme: "default"
    load_controllers: false
assetic:
    use_controller: false

@dantleech
Copy link
Contributor

@alexander-schranz you need to explicitly enable assetic integration, check the README file.

@alexander-schranz
Copy link
Contributor

sorry forget the

    assetic_integration: true

it works awesome @dantleech

@dbu
Copy link
Member

dbu commented Mar 26, 2015

Great! Good work dan!

@dbu dbu closed this as completed Mar 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.