Skip to content

Commit 790abba

Browse files
authored
Read private properties from parent class
1 parent 2fdc67e commit 790abba

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/Vivait/StringGeneratorBundle/EventListener/GeneratorListener.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ public function prePersist(LifecycleEventArgs $args)
6464
$meta = $em->getClassMetadata(get_class($entity));
6565
$this->repo = $em->getRepository($meta->getName());
6666

67-
$object = new \ReflectionObject($entity);
67+
$currentObject = new \ReflectionObject($entity);
68+
$properties = [];
69+
do {
70+
foreach ($currentObject->getProperties() as $property) {
71+
$properties[] = $property;
72+
}
73+
} while (($currentObject = $currentObject->getParentClass()) && (false !== $currentObject));
6874

6975
foreach ($object->getProperties() as $property) {
7076
foreach ($this->reader->getPropertyAnnotations($property) as $annotation) {

0 commit comments

Comments
 (0)