Пример #1
0
 public function register($login, $password)
 {
     if ($this->userRepository->findBySpecification(new LoginSpecification($login))) {
         throw new UserAlreadyExistsException(sprintf('User "%s" already exists', $login));
     }
     $user = new User($login, $password);
     $this->userRepository->add($user);
     $this->uow->commit();
     return $user;
 }
Пример #2
0
 /**
  * Remove post
  *
  * @param int $id
  * @throws DomainException
  */
 public function remove($id)
 {
     $post = $this->getPost($id);
     if ($post === null) {
         throw new DomainException(sprintf('Post "%s" does not exist', $id));
     }
     $post->getAuthor()->removePost($post);
     $this->postRepository->add($post);
     $this->uow->commit();
 }