Esempio n. 1
0
 /**
  * @param User $user
  * @return void
  */
 public function removeUser(User $user)
 {
     if (!$this->repository->findById($user->getId())) {
         throw new NotExistingUserException(sprintf('User with [id = %d] does not exist', $user->getId()));
     }
     $this->repository->remove($user);
     $this->repository->synchronize();
 }
Esempio n. 2
0
 /**
  * @param User $user
  * @throws EditUserException
  *
  */
 private function validateUser(User $user)
 {
     if (!$this->repository->findById($user->getId())) {
         throw new NotExistingUserException(sprintf('User with [id = %d] does not exist', $user->getId()));
     }
     $violations = $this->validator->validate($user);
     if ($violations->count()) {
         throw new EditUserException($violations, 'Invalid User entity.');
     }
 }
 /**
  * @param PhoneNumber $number
  * @param User $user
  * @throws NotExistingUserException
  * @throws AddNumberToUserException
  */
 private function validateInput(PhoneNumber $number, User $user)
 {
     if (!$this->userRepository->findById($user->getId())) {
         throw new NotExistingUserException(sprintf('User with [id = %d] does not exist', $user->getId()));
     }
     $violations = $this->validator->validate($number);
     if ($violations->count()) {
         throw new AddNumberToUserException($violations);
     }
 }
Esempio n. 4
0
 /**
  * @param integer $id
  * @return User|object|null
  */
 public function getUser($id)
 {
     return $this->repository->findById($id);
 }