/**
  * Sends mail
  *
  * @param UserRegistrationInterface $registrationRecord
  * @param string $subject
  * @param string $template
  */
 protected function sendMail(UserRegistrationInterface $registrationRecord, $subject, $template)
 {
     $user = $registrationRecord->getUser();
     $message = $this->mailService->compose(['to' => $user->getEmail()], $template, ['user' => $user, 'registrationRecord' => $registrationRecord]);
     $fromEmail = $this->options->getEmailFromAddress();
     if ($fromEmail) {
         $message->setFrom($fromEmail);
     }
     $message->setSubject($subject);
     return $this->mailService->send($message);
 }
 /**
  * {@inheritDoc}
  */
 public function setPassword(array $data, UserRegistrationInterface $registrationRecord)
 {
     $newPass = $data['newCredential'];
     $user = $registrationRecord->getUser();
     $bcrypt = new Bcrypt();
     $bcrypt->setCost($this->getZfcUserOptions()->getPasswordCost());
     $pass = $bcrypt->create($newPass);
     $user->setPassword($pass);
     $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $user, 'record' => $registrationRecord));
     $this->getUserMapper()->update($user);
     $registrationRecord->setResponded(UserRegistrationInterface::EMAIL_RESPONDED);
     $this->getUserRegistrationMapper()->update($registrationRecord);
     $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array('user' => $user, 'record' => $registrationRecord));
 }