php - Symfony2: Pass _route To Event Listener Service -
I have to pass '_route' from a container as an event listener, along with the route attribute. In other words, I need listener service in which container information needs to be created, the whole service_ container is being overheaded without having to pass in the event listener class.
I have seen a code example like this:
Services: root.path.locator: class: Acme \ bundle \ HelloBundle \ Util \ RootLocator Arguments: ['kernel .root_dir% '] In a controller I will use something like code below to capture "_route":
$ request = $ This- & gt; Container-> Get ('request'); $ RouteName = $ request- & gt; Get ('_ path'); However, in the event listener, I am not available.
How can I do the above?
Thank you,
JB
set From the scope to request the service xml tag, it will automatically inject the requested object, then set @request as an argument in Yaml, area: request and set the argument: [@request] .
Comments
Post a Comment