Bug: Twig cache warmer does not respect twig files on (second) project level

DavidGreiner
DavidGreiner Spryker Backend-Developer Spryker Solution Partner Posts: 11 🧑🏻‍🚀 - Cadet

Hello everyone!
I have a problem with the console command to warm up the Twig caches.
Console twig:cache:warmer
This command doesn't seem to respect our project structure as it should.
structure

  • src
    • <OurProjectNamespace>
      • Yves
    • Pyz
      • Yves

Every time we use the command "console twig:cache:warmer", a file “src/Generated/Yves/Twig/codeBucket/.pathCache” is created. This is fine. But it does not resolve the correct template paths for <OurProject>. Instead, it uses the path to the templates that are located under Pyz.

Fun fact 1: If I create a new “project folder” named “Zzz”, it works as expected. So I suspect the twig:cache:warmer is simply working in alphabetical order instead of using the configured project namespaces.


Fun fact 2: If I load the frontend with running the cache warmer before, the path is also resolved correctly because \Spryker\Shared\Twig\TwigFilesystemLoader is used here, which works with configured project namespaces.

Is this a know bug? Or did we misconfigure something else?

Best

David

Tagged:

Comments

  • Oleksandr Peresypkin
    Oleksandr Peresypkin Lead Demo Engineering Sprykee Posts: 24 ✨ - Novice

    You can try extending this class https://github.com/spryker/twig/blob/master/src/Spryker/Shared/Twig/TwigConfig.php to redefine the paths.

  • DavidGreiner
    DavidGreiner Spryker Backend-Developer Spryker Solution Partner Posts: 11 🧑🏻‍🚀 - Cadet

    Hey! Yes, I could, but that won't help because during
    console twig:cache:warmer only the methods “getDefaultPathCache”, “getYvesThemeName” and “getYvesThemeNameDefault” are used. This is what I tried to describe, the console command does not respect the project namespaces (and also the core namespaces). Instead, it simply goes through the src folder alphabetically and collects the Twig files.

  • ynnoig
    ynnoig Technical Lead eBusiness Spryker Customer Posts: 13 ✨ - Novice
    edited June 10

    Hey @DavidGreiner did u write a workaround for it? If yes, can u please share your solution? Thanks in advance

  • DavidGreiner
    DavidGreiner Spryker Backend-Developer Spryker Solution Partner Posts: 11 🧑🏻‍🚀 - Cadet

    Hey @ynnoig ! No i did not write any workaround or bugfix. I thought it could be planned internally on spryker side to analyze and fix this :) :)