diff --git a/src/ContactEmailer.php b/src/ContactEmailer.php index 73dee83..d76aec2 100644 --- a/src/ContactEmailer.php +++ b/src/ContactEmailer.php @@ -125,10 +125,13 @@ class ContactEmailer { // Stop here if we don't know who to send to. if (!$to) { + // Case: https://atrium.macroweb.hu/oktav/node/33621#comment-179001 + /* $error = $this->t('Unable to determine who to send the message to for for email id @id', [ '@id' => $email->id(), ]); $this->messenger->addWarning($error); + */ continue; } @@ -155,7 +158,26 @@ class ContactEmailer { * The to string to be used by the mail manager. */ protected function getTo(ContactEmailInterface $email) { - $to = $this->removeInvalidEmails($email->getRecipients($this->contactMessage)); + $to = []; + $contact_form_array = $email->get('contact_form')->getValue(); + $contact_form_id = $contact_form_array[0]['target_id']; + if ($contact_form_id == 'jelentkezes' && $email->id() == 2) { + $place_array = $this->contactMessage->get('field_contact_helyszin')->getValue(); + $place = \Drupal::entityTypeManager()->getStorage('node')->load($place_array[0]['target_id']); + if ($place instanceof \Drupal\node\entity\Node) { + $be_notified_array = $place->get('field_be_notified')->getValue(); + foreach ($be_notified_array as $be_notified_index => $be_notified_target) { + $be_notified = \Drupal::entityTypeManager()->getStorage('oktav')->load($be_notified_target['target_id']); + if ($be_notified instanceof \Drupal\eck\Entity\EckEntity) { + $be_notified_email_array = $be_notified->get('field_be_notified_email')->getValue(); + $to[] = $be_notified_email_array[0]['value']; + } + } + } + } + else { + $to = $this->removeInvalidEmails($email->getRecipients($this->contactMessage)); + } return implode(', ', $to); }