protected function isDeletable($object): bool
    {
        $em = $this->getEntityManager();
        $em->beginTransaction();
        try {
            // if an object is softdeleteable, then set 'deletedAt' first, so that a 'hard-delete' will be attempted.
            if ($object instanceof SoftDeleteableInterface) {
                $object->setDeletedAt(new \DateTime());
            }
            $em->remove($object);
            $em->flush();
            $em->rollback();
            return true;
        } catch (ForeignKeyConstraintViolationException $exception) {
            $em->rollback();
            return false;
        }
    }
protected function isDeletable($object): bool
    {
        $em = $this->getEntityManager();
        $em->beginTransaction();
        try {
            // if an object is softdeleteable, then set 'deletedAt' first, so that a 'hard-delete' will be attempted.
            if ($object instanceof SoftDeleteableInterface) {
                $object->setDeletedAt(new \DateTime());
            }
            $em->remove($object);
            $em->flush();
            $em->rollback();
            return true;
        } catch (ForeignKeyConstraintViolationException $exception) {
            $em->rollback();
            return false;
        }
    }
protected function isDeletable ( $ object ) : bool { $ em = $ this -> getEntityManager ( ) ; $ em -> beginTransaction ( ) ; try { // if an object is softdeleteable, then set 'deletedAt' first, so that a 'hard-delete' will be attempted. if ( $ object instanceof SoftDeleteableInterface ) { $ object -> setDeletedAt ( new \ DateTime ( ) ) ; } $ em -> remove ( $ object ) ; $ em -> flush ( ) ; $ em -> rollback ( ) ; return true ; } catch ( ForeignKeyConstraintViolationException $ exception ) { $ em -> rollback ( ) ; return false ; } }
Tries to delete an object without actually deleting it.
Returns false if ForeignKeyConstraintViolationException would be thrown; true otherwise.
Tries to delete an object without actually deleting it . Returns false if ForeignKeyConstraintViolationException would be thrown ; true otherwise .