コード例 #1
0
 public function init()
 {
     if (!$this->job) {
         return false;
     }
     /* @var \Auth\Entity\Info $userInfo */
     $userInfo = $this->user->getInfo();
     $name = $userInfo->getDisplayName();
     if ('' == trim($name)) {
         $name = $userInfo->getEmail();
     }
     $variables = ['name' => $name, 'title' => $this->job->getTitle()];
     $this->setTo($this->user->getInfo()->getEmail(), $this->user->getInfo()->getDisplayName(false));
     $this->setVariables($variables);
     $subject = 'New application for your vacancy "%s"';
     if ($this->isTranslatorEnabled()) {
         $subject = $this->getTranslator()->translate($subject);
     }
     $this->setSubject(sprintf($subject, $this->job->getTitle()));
     /* @var \Applications\Entity\Settings $settings */
     $settings = $this->user->getSettings('Applications');
     $body = $settings->getMailAccessText();
     if ('' == $body) {
         $body = "Hello ##name##,\n\nThere is a new application for your vacancy:\n\"##title##\"\n\n";
         if ($this->isTranslatorEnabled()) {
             $body = $this->getTranslator()->translate($body);
         }
     }
     $this->setBody($body);
     return $this;
 }