Add token support for participant & membership tasks
[civicrm-core.git] / CRM / Member / Form / Task / Email.php
index 5e0e6d4baa61941ac9092f1cad8a107fe7d10e07..9f19d0fe7ee6d8a57f0ca0f3065a39acd53a26f8 100644 (file)
 class CRM_Member_Form_Task_Email extends CRM_Member_Form_Task {
   use CRM_Contact_Form_Task_EmailTrait;
 
+  /**
+   * Only send one email per contact.
+   *
+   * This has historically been done for contributions & makes sense if
+   * no entity specific tokens are in use.
+   *
+   * @return bool
+   * @throws \CRM_Core_Exception
+   */
+  protected function isGroupByContact(): bool {
+    return !empty($this->getMessageTokens()['membership']);
+  }
+
 }