public function updateUser(User $user) { $user->setEmail($this->email); $user->setName($this->name); return $user; }
public function createOrFindUserByEmail($email) { $user = false; try { $user = $this->findUserByEmail($email); } catch (EntityNotFoundException $e) { //user not found create one } if (!$user) { $user = new User(); $user->setEmail($email); $user->setEnabled(false); $event = new UserEvent($user); $this->dispatcher->dispatch(UserEvents::EMAIL_REGISTRATION_SUCCESS, $event); $this->entityManager->persist($user); $this->entityManager->flush(); } return $user; }