示例#1
0
 public function getVocabulary(User $user)
 {
     $randomUserVocabularyId = $this->userVocabularyRepository->getRandomUserVocabularyId($user->getId(), $this->correctAnswersLimit);
     $filter = new UserVocabularyFilter();
     $filter->setId($randomUserVocabularyId);
     return $this->userVocabularyRepository->fetch($filter);
 }
示例#2
0
 public function findVocabulary($englishVocabulary, User $user)
 {
     $filter = new UserVocabularyFilter();
     $filter->setEnglishVocabulary($englishVocabulary);
     $filter->setUserId($user->getId());
     return $this->userVocabularyRepository->fetch($filter);
 }
 private function findUserVocabulary(Vocabulary $vocabulary, User $user)
 {
     $filter = new UserVocabularyFilter();
     $filter->setVocabularyId($vocabulary->getId());
     $filter->setUserId($user->getId());
     return $this->userVocabularyRepository->fetch($filter);
 }
示例#4
0
 public function getLearnedVocabularyByDayCumulative(User $user, Date $startDate, $dayInterval)
 {
     $dbData = $this->userVocabularyRepository->getLearnedVocabularyStatsByDate($user->getId(), $this->correctAnswersLimit, $startDate);
     $vocabularyCountBeforeDate = $this->userVocabularyRepository->getLearnedVocabularySumBeforeDate($user->getId(), $this->correctAnswersLimit, $startDate);
     $dbData = $this->vocabularyDataPreparer->getNewKeywordsByDay($dbData, $startDate, $dayInterval);
     $dbData = $this->addCumulativeCount($dbData, $vocabularyCountBeforeDate);
     return $dbData;
 }
示例#5
0
 public function sendToUser(MailMessage $mailMessage, User $recipientUser, EmailAddress $replyTo = null, EmailAddress $from = null)
 {
     if (!$recipientUser->getActive()) {
         throw new Exception('User ' . $recipientUser->getId() . ' is inactive');
     }
     $recipientName = strlen($recipientUser->getName()) ? $recipientUser->getName() : null;
     $recipient = new EmailAddress($recipientUser->getEmail(), $recipientName);
     $this->sendToAddress($mailMessage, $recipient, $replyTo, $from);
 }
示例#6
0
 private function createNewPasswordUser($name, $email, $password, $ipAddress)
 {
     $user = new User($email);
     $user->setName($name);
     $user->setCreatedAt($this->dateTimeFactory->getCurrentDateTime()->toDateTime());
     $user->setRegistrationIpAddress($ipAddress);
     $user->setRole(User::ROLE_USER);
     if ($password) {
         $user->setPassword(password_hash($password, PASSWORD_BCRYPT, ['cost' => $this->bcryptIterations]));
     }
     $this->userRepository->save($user);
     return $user;
 }
示例#7
0
 public function sendWelcomeEmail(User $user)
 {
     $mailVariables = array('name' => $user->getName());
     $mailMessage = $this->templateFactory->create('welcomeEmail', __DIR__ . '/WelcomeEmailCreator', 'cs', $mailVariables);
     $this->mailer->sendToUser($mailMessage, $user);
 }