/**
  * @param ConsumerRegistrationRequestInterface $request
  *
  * @return Consumer
  *
  * @throws DomainException
  */
 public function handle(ConsumerRegistrationRequestInterface $request)
 {
     $consumerEntity = $request->getConsumerEntity();
     $gguid = UUID::generate();
     $username = new Username($consumerEntity->getUsername());
     $password = new Password($consumerEntity->getPassword());
     $this->validateUsernameIsUnique($username);
     $consumer = new Consumer($gguid, $username, $password);
     $this->consumerRepository->persist($consumer);
     $this->getEventDispatcher()->trigger(new ConsumerRegisteredEvent($gguid));
     return $consumer;
 }
Ejemplo n.º 2
0
 /**
  * @param UUID $uuid
  * @param Username $username
  * @param Password $password
  */
 public function __construct(UUID $uuid, Username $username, Password $password)
 {
     $this->uuid = $uuid->getValue();
     $this->username = $username->getValue();
     $this->password = $password->getValue();
 }