Beispiel #1
0
 /**
  * Run notification process through a chain
  * @param string $message
  * @param array $sentEmails
  * @return array
  */
 public function handle($message, $sentEmails = [])
 {
     $emailsToSend = $this->getEmailsToSend();
     $sent = [];
     foreach ($emailsToSend as $email) {
         if (!in_array($email, $sentEmails, true)) {
             $this->notify($email, $message);
             $sent[] = $email;
         }
     }
     $sentEmails = array_merge($sentEmails, $sent);
     if (!is_null($this->successor)) {
         return $this->successor->handle($message, $sentEmails);
     }
     return $sentEmails;
 }