public function __invoke(ApplicationEvent $event)
 {
     $this->application = $event->getApplicationEntity();
     $this->sendRecruiterMails();
     $this->sendCarbonCopyToCandidate();
 }
示例#2
0
 /**
  * Sends the Notification Mail.
  *
  * @param ApplicationEvent $event
  */
 public function sendMail(ApplicationEvent $event)
 {
     if (!$event->isPostRequest()) {
         return;
     }
     $this->application = $event->getApplicationEntity();
     $status = $event->getStatus();
     $user = $event->getUser();
     $post = $event->getPostData();
     $settings = $user->getSettings('Applications');
     $recipient = $this->getRecipient($this->application, $status);
     /* @var \Applications\Mail\StatusChange $mail */
     $mail = $this->mailService->get('Applications/StatusChange');
     $mail->setSubject($post['mailSubject']);
     $mail->setBody($post['mailText']);
     $mail->setTo($recipient);
     if ($from = $this->application->getJob()->getContactEmail()) {
         $mail->setFrom($from, $this->application->getJob()->getCompany());
     }
     if ($settings->mailBCC) {
         $mail->addBcc($user->getInfo()->getEmail(), $user->getInfo()->getDisplayName());
     }
     $job = $this->application->getJob();
     $jobUser = $job->getUser();
     if ($jobUser->getId() != $user->getId()) {
         $jobUserSettings = $jobUser->getSettings('Applications');
         if ($jobUserSettings->getMailBCC()) {
             $mail->addBcc($jobUser->getInfo()->getEmail(), $jobUser->getInfo()->getDisplayName(false));
         }
     }
     $org = $job->getOrganization()->getParent(true);
     $orgUser = $org->getUser();
     if ($orgUser->getId() != $user->getId() && $orgUser->getId() != $jobUser->getId()) {
         $orgUserSettings = $orgUser->getSettings('Applications');
         if ($orgUserSettings->getMailBCC()) {
             $mail->addBcc($orgUser->getInfo()->getEmail(), $orgUser->getInfo()->getDisplayName(false));
         }
     }
     $this->mailService->send($mail);
     $historyText = sprintf($this->translator->translate('Mail was sent to %s'), key($recipient) ?: $recipient[0]);
     $this->application->changeStatus($status, $historyText);
     $event->setNotification($historyText);
 }