diff --git a/Civi/Mailinglistsync/EventMailingList.php b/Civi/Mailinglistsync/EventMailingList.php index 79898b2..18af9de 100644 --- a/Civi/Mailinglistsync/EventMailingList.php +++ b/Civi/Mailinglistsync/EventMailingList.php @@ -25,7 +25,7 @@ class EventMailingList extends BaseMailingList { * @return array */ protected function getEntity(): array { - return $this->event ?? NULL; + return $this->event; } /** @@ -39,6 +39,12 @@ class EventMailingList extends BaseMailingList { $this->event = $value; } + /** + * Get a list of recipients indexed by email address. + * + * @return array List of recipients (MailListRecipient) + * @throws \Civi\Mailinglistsync\Exceptions\MailinglistException + */ public function getRecipients(): array { try { $recipientData = Contact::get() @@ -72,7 +78,7 @@ class EventMailingList extends BaseMailingList { ); } catch (\Exception $e) { throw new MailinglistException( - "Could not create recipient object for contact with id '{$recipient['id']}'\n$e", + "Could not create recipient object for contact with id '{$recipient['id']}': $e", MailinglistException::ERROR_CODE_GET_RECIPIENTS_FAILED ); } diff --git a/Civi/Mailinglistsync/GroupMailingList.php b/Civi/Mailinglistsync/GroupMailingList.php index d51e001..e998783 100644 --- a/Civi/Mailinglistsync/GroupMailingList.php +++ b/Civi/Mailinglistsync/GroupMailingList.php @@ -110,7 +110,7 @@ class GroupMailingList extends BaseMailingList { } catch (\Exception $e) { throw new MailinglistException( - "Could not get recipients for group with id '{$this->group['id']}'\n$e", + "Could not get recipients for group with id '{$this->group['id']}': {$e->getMessage()}", MailinglistException::ERROR_CODE_GET_RECIPIENTS_FAILED ); } diff --git a/api/v3/Mailinglistsync/Mlmmjsync.php b/api/v3/Mailinglistsync/Mlmmjsync.php index 6eca4e0..ceed3e1 100644 --- a/api/v3/Mailinglistsync/Mlmmjsync.php +++ b/api/v3/Mailinglistsync/Mlmmjsync.php @@ -122,6 +122,7 @@ function civicrm_api3_mailinglistsync_Mlmmjsync($params) { } foreach ($mailingListsToSync as $mailingList) { + /* @var \Civi\Mailinglistsync\BaseMailingList $mailingList */ $results['mailing_lists'][$mailingList->getEmailAddress()] = $mailingList->sync(); // TODO: re-add failed task to queue } diff --git a/mailinglistsync.php b/mailinglistsync.php index 97ee9df..4f5f6d1 100644 --- a/mailinglistsync.php +++ b/mailinglistsync.php @@ -174,26 +174,6 @@ function mailinglistsync_civicrm_validateForm($formName, &$fields, &$files, &$fo } } - - -function mailinglistsync_civicrm_pre($op, $objectName, $objectId, &$params) { - if ($op === 'delete' || $op === 'edit') { - - if ($objectName === 'Group' || $objectName === 'Event') { - $mailingList = $objectName === 'Group' - ? new GroupMailingList($objectId) - : new EventMailingList($objectId); - if ($mailingList->isEnabled()) { - - // If email has changed, delete the mailing list and create a new one - if ($mailingList->getEmailAddress() !== $params['email']) { - // - } - } - } - } -} - /** * Implements hook_civicrm_post() to check on permissions to alter mailing list * groups and sync group with mlmmj.