/**
  * @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();
 }
Example #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);
     }
 }
 /**
  * @inheritDoc
  */
 public function findUserNumber(User $user, $numberId)
 {
     return $this->createQueryBuilder('pn')->where('pn.owner = :user_id')->andWhere('pn.id = :number_id')->setParameter('user_id', $user->getId(), \PDO::PARAM_INT)->setParameter('number_id', $numberId, \PDO::PARAM_INT)->getQuery()->getOneOrNullResult();
 }