コード例 #1
0
 /**
  * Handle the command.
  *
  * @param ContactFormBuilder $builder
  * @param MessageBag         $messages
  * @param Mailer             $mailer
  */
 public function handle(ContactFormBuilder $builder, MessageBag $messages, Mailer $mailer)
 {
     // Validation failed!
     if ($builder->hasFormErrors()) {
         return;
     }
     // Delegate these for now.
     $view = $this->dispatch(new GetMessageView($builder));
     $data = $this->dispatch(new GetMessageData($builder));
     // Build the message object.
     $message = function (Message $message) use($builder) {
         $this->dispatch(new BuildMessage($message, $builder));
     };
     // Send the email.
     $mailer->send($view, $data, $message);
     // If there are any failures, report.
     if (count($mailer->failures()) > 0) {
         $messages->error($builder->getFormOption('error_message', 'anomaly.plugin.contact::error.send_message'));
     } else {
         // Otherwise, show success.
         $messages->success($builder->getFormOption('success_message', 'anomaly.plugin.contact::success.send_message'));
     }
     // Clear the form!
     $builder->resetForm();
 }
コード例 #2
0
 /**
  * Handle the form.
  *
  * @param ForgotPasswordFormBuilder $builder
  * @param UserRepositoryInterface   $users
  * @param UserPassword              $password
  * @param MessageBag                $messages
  * @param Repository                $config
  */
 public function handle(ForgotPasswordFormBuilder $builder, UserRepositoryInterface $users, UserPassword $password, MessageBag $messages, Repository $config)
 {
     if ($builder->hasFormErrors()) {
         return;
     }
     $user = $users->findByEmail($builder->getFormValue('email'));
     if ($path = $builder->getFormOption('reset_path')) {
         $config->set('anomaly.module.users::paths.reset', $path);
     }
     $password->forgot($user);
     $password->send($user, $builder->getFormOption('reset_redirect'));
     $messages->success('anomaly.module.users::message.confirm_reset_password');
 }
コード例 #3
0
 /**
  * Handle the command.
  *
  * @param InviteFormBuilder $builder
  * @param MessageBag $messages
  */
 public function handle(InviteFormBuilder $builder, MessageBag $messages)
 {
     // Validation failed!
     if ($builder->hasFormErrors()) {
         return;
     }
     $reply = $this->dispatch(new SendInvite($builder));
     if (array_get($reply, 'ok') === true) {
         $messages->success('anomaly.extension.slack_inviter::success.send_invite');
     } else {
         $messages->error('anomaly.extension.slack_inviter::error.send_invite');
         $messages->error('anomaly.extension.slack_inviter::error.' . $reply['error']);
     }
     // Clear the form!
     $builder->resetForm();
 }
コード例 #4
0
 /**
  * Handle the form.
  *
  * @param UserRepositoryInterface  $users
  * @param ResetPasswordFormBuilder $builder
  * @param MessageBag               $messages
  * @param UserPassword             $password
  */
 public function handle(UserRepositoryInterface $users, ResetPasswordFormBuilder $builder, MessageBag $messages, UserPassword $password)
 {
     $user = $users->findByEmail($builder->getEmail());
     /**
      * If we can't find the user by the email
      * provided then head back to the form.
      */
     if (!$user) {
         $messages->error(trans('anomaly.module.users::error.reset_password'));
         return;
     }
     /**
      * If we can't successfully reset the
      * provided user then back back to the form.
      */
     if (!$password->reset($user, $builder->getCode(), $builder->getFormValue('password'))) {
         $messages->error(trans('anomaly.module.users::error.reset_password'));
         return;
     }
     $messages->success(trans('anomaly.module.users::success.reset_password'));
 }