What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
We want to render PDF files. And we use twig for that because it is HTML to PDF. Our problem now is
We want to render PDF files. And we use twig for that because it is HTML to PDF. Our problem now is how to get a fully configured Twig Service? If we setup twig ourself we would have to inject loads of different things. We found a twig trait but those functions only use an existing twig. The Controller has an already setup twig but I don't think it is wise to inject that somewhere else. So how do I get a fully setup twig from the global scope?
Comments
-
We are using the
\Spryker\Yves\Twig\TwigFactory
still that is missing the trans function0 -
you can access the global (app) container from the controller I think?
0 -
so maybe you could register your service in the app container and use it in the controller? (i.e. implement it "outside" of Spryker)
0 -
not sure if it's currently possible to provide global dependencies in the dependency providers
0 -
We have twig configured for controllers. That is done during the bootstrap. But as we use a DTO for the data to get that in our PDF service we loose the reference. So now we do the translation inside of the controller and pass those translated strings to the DTO.
0 -
Maybe I am missing something but from my Symfony perspective I would just inject the service and all would be fine. That seems not to be possible in Spryker.
0 -
no, it's not AFAIK
0 -
Ricardo did know what to do! β€ So you have to build inside of your DI a new Pimple instance and that can give you a new globally configured twig for you. Probably wasts loads of resources
0 -
Yes you can load the Application from the Pimple (inside the Factory of cause) and from there you can get the current Twig Env
0 -
so rebuild the container from scratch? or?
0 -
Yes with a nice and shiny new Pimpel() π§‘
0 -
β
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random