コード例 #1
0
ファイル: ProfilePresenter.php プロジェクト: blitzik/vycetky
 public function processSendKey(Form $form)
 {
     $value = $form->getValues();
     try {
         $invitation = $this->userManager->createInvitation($value['email']);
     } catch (UserAlreadyExistsException $uae) {
         $this->flashMessage('Pozvánku nelze odeslat. Uživatel s E-Mailem ' . $value['email'] . ' je již zaregistrován.', 'warning');
         $this->redirect('this');
     } catch (InvitationAlreadyExistsException $iae) {
         $this->flashMessage('Pozvánka již byla odeslána uživateli s E-mailem ' . $value['email'], 'warning');
         $this->redirect('this');
     }
     try {
         $this->emailNotifier->send('Výčetkový systém <' . $this->emails['system'] . '>', $invitation->email, function (ITemplate $template, Invitation $invitation, $senderName) {
             $template->setFile(__DIR__ . '/../../model/Notifications/templates/invitation.latte');
             $template->invitation = $invitation;
             $template->username = $senderName;
         }, [$invitation, $this->getUser()->getIdentity()->username]);
         $this->flashMessage('Registrační pozvánka byla odeslána', 'success');
     } catch (InvalidStateException $e) {
         $this->userManager->removeInvitation($invitation);
         Debugger::log($e, Debugger::ERROR);
         $this->flashMessage('Registrační pozvánku nebylo možné odeslat. Zkuste to prosím později.', 'error');
     }
     $this->redirect('this');
 }