Calling Developers!
We are reenergizing our code contribution process! Learn More

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

Options
DavidGreiner
DavidGreiner Spryker Backend-Developer Spryker Solution Partner Posts: 7 🧑🏻‍🚀 - 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
    Options

    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: 7 🧑🏻‍🚀 - Cadet
    Options

    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: 12 ✨ - Novice
    edited June 10
    Options

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