public function onFlush(OnFlushEventArgs $args)
    {
        $em  = $args->getEntityManager();
        $uow = $em->getUnitOfWork();

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            $classMetadata = $em->getClassMetadata(get_class($entity));
            if ($this->isSoftDeletable($classMetadata)) {
                $oldValue = $entity->getDeletedAt();

                $entity->delete();
                $em->persist($entity);

                $uow->propertyChanged($entity, 'deletedAt', $oldValue, $entity->getDeletedAt());
                $uow->scheduleExtraUpdate($entity, [
                    'deletedAt' => [$oldValue, $entity->getDeletedAt()]
                ]);
            }
        }
    }
public function onFlush(OnFlushEventArgs $args)
    {
        $em  = $args->getEntityManager();
        $uow = $em->getUnitOfWork();

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            $classMetadata = $em->getClassMetadata(get_class($entity));
            if ($this->isSoftDeletable($classMetadata)) {
                $oldValue = $entity->getDeletedAt();

                $entity->delete();
                $em->persist($entity);

                $uow->propertyChanged($entity, 'deletedAt', $oldValue, $entity->getDeletedAt());
                $uow->scheduleExtraUpdate($entity, [
                    'deletedAt' => [$oldValue, $entity->getDeletedAt()]
                ]);
            }
        }
    }
public function onFlush ( OnFlushEventArgs $ args ) { $ em = $ args -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityDeletions ( ) as $ entity ) { $ classMetadata = $ em -> getClassMetadata ( get_class ( $ entity ) ) ; if ( $ this -> isSoftDeletable ( $ classMetadata ) ) { $ oldValue = $ entity -> getDeletedAt ( ) ; $ entity -> delete ( ) ; $ em -> persist ( $ entity ) ; $ uow -> propertyChanged ( $ entity , 'deletedAt' , $ oldValue , $ entity -> getDeletedAt ( ) ) ; $ uow -> scheduleExtraUpdate ( $ entity , [ 'deletedAt' => [ $ oldValue , $ entity -> getDeletedAt ( ) ] ] ) ; } } }
Listens to onFlush event.

@param OnFlushEventArgs $args The event arguments
Listens to onFlush event .