For an API project I want to fail very early, before the controller is dispatched, if the input data is incorrect. I’ve managed to get the validation done by using the route defaults and an event subscriber subscribing to the KernelEvents::REQUEST event. As you can see in the code, I’m trying to get the validator from the container. My assumption
Tag: service-locator
Avoid Service locator in strategy design pattern [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 8 months ago. Improve this question Take a look on that pseudocode As service locator is considered as anti pattern, how to avoid it in this case?
How do I get a service from the container directly, if I didn’t/couldn’t inject the service using DI?
I have a part of code where I’m injecting two services $checker and $paginator by dependency injection. It works perfectly: public function index(Request $request, Paginator $paginator, Checker $…