Beispiel #1
0
 /**
  * @param int $id
  * @param string $key
  */
 public function activateUser($id, $key)
 {
     $this->userMapper->setSelectedRecordStatus(\Model\Common\RecordStatus::UNFINISHED);
     $user = $this->userMapper->findByPk($id);
     /** @var User $user */
     $this->userMapper->setSelectedRecordStatus(\Model\Common\RecordStatus::VALID);
     if (!is_null($user)) {
         $key = $this->actionKeyMapper->findByKey($key);
         if (!is_null($key)) {
             $user->setStatus(\Model\Common\RecordStatus::VALID);
             $this->saveUser($user);
             $key->setStatus(\Model\Common\RecordStatus::DELETED);
             $this->actionKeyMapper->save($key);
         } else {
             throw new \Nette\UnexpectedValueException("forms.register.errors.not-exists-key");
         }
     } else {
         throw new \Nette\UnexpectedValueException("forms.register.messages.already-activated");
     }
 }