Skip to content

Doctrine event listener and softdeleted filter #369

Description

@shubaivan

I have entity answers and I use softdeleted filter for them, and when I remove entity in some action everything fine, I have deletedAt datetime, but when I try remove this entity in OnFlushEvent my entity is gone from DB, why ?

 public function onFlush(OnFlushEventArgs $args)
{
    $em = $args->getEntityManager();
    $uow = $em->getUnitOfWork();
    $em->getFilters()->enable('softdeleteable');
    foreach ($uow->getScheduledEntityUpdates() as $entity) {
        if ($entity instanceof Questions) {
            $existAnswers = $this->container->get('app.repository.question_answers')
                ->findOneBy(['questions' => $entity]);
                        $em->remove($existAnswers);                                                          
        }
    }
}

entity

 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 */
class QuestionAnswers

I checked, this filter enabled, I try force enable but no helped

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions