コード例 #1
0
 /**
  * Create an email entity from an array and populate with default data
  *
  * @param  array  $data Data to populate the email
  * @return Email
  */
 public function createFromArray(array $data)
 {
     $headers = json_encode(Arr::path($this->emailConfig, 'defaults.headers', []));
     $defaults = ['headers' => $headers, 'sender_email' => Arr::path($this->emailConfig, 'defaults.sender.email'), 'sender_name' => Arr::path($this->emailConfig, 'defaults.sender.name')];
     $email = $this->emailMapper->getPrototype();
     $email = $email->exchangeArray(array_merge($defaults, $data));
     $email = $this->emailMapper->persist($email);
     return $email;
 }
コード例 #2
0
 /**
  * Create an email entity from an array and populate with default data
  *
  * @param  array  $data Data to populate the email
  * @return Email
  */
 public function createFromArray(array $data)
 {
     $headers = json_encode(Arr::path($this->emailConfig, 'defaults.headers', []));
     if (isset($data['sender_localpart'])) {
         if (!Arr::path($this->emailConfig, 'defaults.sender.domain')) {
             throw new \Exception('defaults.sender.domain not set in email config');
         }
         $data['sender_email'] = Arr::remove($data, 'sender_localpart') . '@' . Arr::path($this->emailConfig, 'defaults.sender.domain');
     }
     $defaults = ['headers' => $headers, 'sender_email' => Arr::path($this->emailConfig, 'defaults.sender.email'), 'sender_name' => Arr::path($this->emailConfig, 'defaults.sender.name')];
     $email = $this->emailMapper->getPrototype();
     $email = $email->exchangeArray(array_merge($defaults, $data));
     $email = $this->emailMapper->persist($email);
     return $email;
 }