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..
Hey! I know that an instance of `\Symfony\Component\HttpFoundation\Request` can be injected into Yv
Hey! I know that an instance of \Symfony\Component\HttpFoundation\Request
can be injected into Yves’ controller action method. I know also that a path parameter can be also injected into controller action method. Is there a way to use constructor- or method-injection for the services needed in controller? Or using factory is the only way to get required dependencies into Yves controller?
Comments
-
The
Request
passed into a controller action is the current request and should not be used as a service, but only to get access to the content of the current request (e.g.: query parameters).
Controllers in Spryker are not services like in Symfony, they are but they can't be modified to inject additional dependencies, that's why dependencies are retrieved via factory. The reason therefore is the core/project/code bucket inheritance logic in Spryker that comes with a locator that find's the right controller automatically.0 -
Thank you, Alberto! I just needed to be sure that using factory is the only and true Spryker way to use dependencies in controllers.
0 -
@U0310RKK9U7 Controllers have an overridable
initialize()
method.I like using it to only having to resolve for dependenceis exactly once.
0 -
That’s nice! Thank you, @UQ958DA4U
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