Reputation: 1985
I want to create a service in Symfony2 that will take in the current request on the constructor and use it to determine the type of browser used for the request.
I can create the class and define it as a service but how do I pass in the current request using the XML service definition?
Upvotes: 3
Views: 1638
Reputation: 6986
You should be able to just use the request
service. This however requires your service to be declared with scope="request"
. Another approach i used was to inject the service-container and retrieve the request
-Service form there when you need it.
Upvotes: 5