toArray(); $existingUser = $this->userRepository->findOneBy(['email'=> $requestArray['email']]); if (!is_null($existingUser)) { throw new HttpException(400,'Ya hay un usuario registrado con este correo.'); } $this->entityManager->remove((object)$existingUser); $this->entityManager->flush(); $this->entityManager->clear(); return new JsonResponse( data: [ 'success' => true, 'message' => 'Usuario eliminado.' ], status: Response::HTTP_OK ); } }