[Flow] How to retrieve all methods of a class that have a certain annotation?

Robert Lemke robert at typo3.org
Thu Aug 29 10:09:41 CEST 2013


Hi Christian,

Christian Loock wrote:

> so I want to get all methodnames of a given class, that have a certain
> annotation.
>
> It seems like, the refelectionservice, only has methods, that retrieve
> data from a specific method, but none to actually retrieve the methods
> of a class.
>
> Is that the case or did I overlook something?

that's right. You can use

	getClassesContainingMethodsAnnotatedWith($annotationClassName)

for retrieving all potential classes which contain methods annotated 
with the annotation you're looking for. Then you'll need to iterate over 
the methods and check their annotations, for example with

	isMethodAnnotatedWith($className, $methodName, $annotationClassName)

Why there is no function which does all the work for you? The additional 
cache data we'd need for that information would be huge (we had that in 
the past) which effectively would slow down the whole application.

Cheers,
Robert



More information about the Flow mailing list