I want read custom annotations like @Route for Controllers. I will use it for eventlisteners like this:
/**
* @Event("some.event");
*/
public function onSomeEvent(Event $event) {}
I found out, I can use an annotation-reader or simple php-reflections for analysing the docblock. Which event I should listen to to trigger my reader? Or can someone give me a hint how it works with @Route-annotations? I need almost the same logic, but I missed obviously some important points by reading the symfony code.
Take a look at the code in the
ControllerListenerclass within SensioFrameworkExtraBundle. It is registered as akernel.event_listenerhere.This listener reads/parses the annotations provided by that bundle. The annotations provided by SensioFrameworkExtraBundle are located here.
You should be able to simply mimic one of the bundle’s provided annotations to accomplish your needs.