I have implemented my own Doctrine\Common\EventSubscriber that subscribes to "onFlush" events and compares the EntityChangeSet to a hard coded list of class properties (like User->Name and Event->Date) and logs the change if necessary.
As property names of the other classes might change, I'd much rather prefer to annotate these properties with a custom made @Loggable.
I have built the Annotation class "Loggable", added use MyNamespace\Annotations\Loggable; to the User and Event classes and have a method in my EventSubscriber that creates a Doctrine\Common\Annotations\AnnotationReader and uses its getPropertyAnnotation($property, 'Loggable') to check for a non-null value.
Now to the problem
As one could expect (or not), this particular reader throws
[Semantical Error] The annotation "@Id" in property MyNamespace\Entities\User::$id was never imported.
and is not aware of any other ORM-annotations that the reader in my EntityManager knows about.
Do I actually have to add use Doctrine\ORM\Mapping as ORM; to every Entity class and prefix every ORM-annotation with ORM\ just to please this newly created reader or is there a way to reuse the reader in my EntityManager (a Doctrine\Common\Annotations\SimpleAnnotationReader by default, if I understood correctly?)
I did my research and read through most of the answers related to Doctrine and Annotations, but I seem to be missing some conceptual understanding. Maybe someone can point me in the right direction?
use) the annotations that I use. I suppose that would be the clean way.