Skip to content

Commit

Permalink
Merge pull request #41 from terox/terox-reflection-private-properties
Browse files Browse the repository at this point in the history
Read private properties from parent class
  • Loading branch information
kieljohn authored Oct 14, 2019
2 parents c20d8a3 + 9d34f61 commit df49d18
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down

0 comments on commit df49d18

Please sign in to comment.