Hey James, You will have to use a custom annotation reader for this. Annotations are just metadata attached to a property, but they are not aware of the context they are placed in.
Wherever you want an annotation for a property, you need an instance of the ReflectionProperty anyway, so the two are very accessible from a context where you'd read the annotation from the AnnotationReader. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 17 September 2015 at 04:35, James Murray <[email protected]> wrote: > simple question: > > I'm making some custom annotations that needs to have access to the > field(property) name that the annotation is used on. > > Is there a way to retrieve the field/property name in my annotation class? > > for instance > class myAwesomeEntity { > /** > * @column(name="some_db_field") > * @myCustomAnnotation() > private $someDBField; > } > > now in my annotation: > class MyCustomAnnotation > { > public $fieldName; > > public function __construct() > { > $this->fieldName = /*???*/ > } > } > > when I read/use my property annotation I'd like to have the $fieldName > property hydrated with the name of the property that's using the annotation > so in this case: > > echo $myCustomAnnotation->fieldNam; //someDBField -or- some_db_field > > > OR I have to set this when I'm actually reading the annotation instead of > being able to gather the property metadata inside the annotation? > > Thanks for the help > > -- > You received this message because you are subscribed to the Google Groups > "doctrine-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/doctrine-user. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
