diff --git a/src/Vivait/StringGeneratorBundle/EventListener/GeneratorListener.php b/src/Vivait/StringGeneratorBundle/EventListener/GeneratorListener.php index cd18ef0..d4a0287 100644 --- a/src/Vivait/StringGeneratorBundle/EventListener/GeneratorListener.php +++ b/src/Vivait/StringGeneratorBundle/EventListener/GeneratorListener.php @@ -51,9 +51,16 @@ public function prePersist(LifecycleEventArgs $args) $meta = $em->getClassMetadata(get_class($entity)); $this->repo = $em->getRepository($meta->getName()); - $object = new \ReflectionObject($entity); + $currentObject = new \ReflectionObject($entity); + $properties = []; + do { + foreach ($currentObject->getProperties() as $property) { + $properties[] = $property; + } + } while (($currentObject = $currentObject->getParentClass()) && (false !== $currentObject)); - foreach ($object->getProperties() as $property) { + /** @var \ReflectionProperty[] $property */ + foreach ($properties as $property) { foreach ($this->reader->getPropertyAnnotations($property) as $annotation) { if ($annotation instanceof GeneratorAnnotation) {