I'm currently in a listener, and I want to return some headers in my response. $this->router->match($this->request->getPathInfo());
I don't have any information about this. I have however specified the methods :
api_v2_spokespeople_collection:
path: /spokespeople
defaults: { _controller: "APIBundle:v2/Spokesperson:getCollection" }
methods: [GET, OPTIONS]
Is it finally possible without having to "manually" parse the routing files?
If you have a route name:
and you have the
@router
service (It seems this service was injected into your listener):then we can get the route instance and its information through route collection:
finally, you need to call to
getMethods()
to know the defined methods:In one line: