public function onFlush(OnFlushEventArgs $args): void
    {
        // Get the entity manager and unit of work.
        $em = $args->getEntityManager();
        $uow = $em->getUnitOfWork();

        // Check insertions for new events.
        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            foreach ($this->getInvitations($entity) as $invitation) {
                $em->persist($invitation);
                $uow->computeChangeset($em->getClassMetadata(Invitation::class), $invitation);
            }
        }

        // Check updates for updated events.
        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            foreach ($this->getInvitations($entity) as $invitation) {
                $em->persist($invitation);
                $uow->computeChangeset($em->getClassMetadata(Invitation::class), $invitation);
            }
        }
    }
public function onFlush(OnFlushEventArgs $args): void
    {
        // Get the entity manager and unit of work.
        $em = $args->getEntityManager();
        $uow = $em->getUnitOfWork();

        // Check insertions for new events.
        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            foreach ($this->getInvitations($entity) as $invitation) {
                $em->persist($invitation);
                $uow->computeChangeset($em->getClassMetadata(Invitation::class), $invitation);
            }
        }

        // Check updates for updated events.
        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            foreach ($this->getInvitations($entity) as $invitation) {
                $em->persist($invitation);
                $uow->computeChangeset($em->getClassMetadata(Invitation::class), $invitation);
            }
        }
    }
public function onFlush ( OnFlushEventArgs $ args ) : void { // Get the entity manager and unit of work. $ em = $ args -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; // Check insertions for new events. foreach ( $ uow -> getScheduledEntityInsertions ( ) as $ entity ) { foreach ( $ this -> getInvitations ( $ entity ) as $ invitation ) { $ em -> persist ( $ invitation ) ; $ uow -> computeChangeset ( $ em -> getClassMetadata ( Invitation :: class ) , $ invitation ) ; } } // Check updates for updated events. foreach ( $ uow -> getScheduledEntityUpdates ( ) as $ entity ) { foreach ( $ this -> getInvitations ( $ entity ) as $ invitation ) { $ em -> persist ( $ invitation ) ; $ uow -> computeChangeset ( $ em -> getClassMetadata ( Invitation :: class ) , $ invitation ) ; } } }
Listens for the onFlush event.

@param OnFlushEventArgs $args The arguments for this event.

@return void
Listens for the onFlush event .