Symfony 3 / Doctrine - Get changes to associations in entity change set

Viewed 3889

So I already know that I can get changes to a specific entity in the preUpdate lifecycle event:

/**
 * Captures pre-update events.
 * @param PreUpdateEventArgs $args
 */
 public function preUpdate(PreUpdateEventArgs $args)
 {
     $entity = $args->getEntity();


     if ($entity instanceof ParentEntity) {
            $changes = $args->getEntityChangeSet();
     }
 }

However, is there a way to also get changes for any associated Entities? For example, say ParentEntity has a relationship setup like so:

/**
 * @ORM\OneToMany(targetEntity="ChildEntity", mappedBy="parentEntity", cascade={"persist", "remove"})
 */
 private $childEntities;

And ChildEntity also has:

/**
 * @ORM\OneToMany(targetEntity="GrandChildEntity", mappedBy="childEntity", cascade={"persist", "remove"})
 */
 private $grandChildEntities;

Is there a way to get all relevant changes during the preUpdate of ParentEntity?

2 Answers
Related