3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
11 namespace Civi\FlexMailer
;
14 * Class FlexMailerTask
15 * @package Civi\FlexMailer
17 * A FlexMailerTask describes an individual message that needs to be
18 * composed and delivered. Generally, it's used in three steps:
19 * - At the start, we instantiate the task with a few inputs
20 * (e.g. $contactId and $address).
21 * - During composition, we read those values and fill-in the
22 * message's content ($task->setMailParams(...));
23 * - During delivery, we read the message ($task->getMailParams())
26 class FlexMailerTask
{
30 * A persistent record for this email delivery.
31 * @see \CRM_Mailing_Event_DAO_Queue
33 private $eventQueueId;
37 * The ID of the recipiient.
38 * @see \CRM_Contact_DAO_Contact
44 * An authentication code. The name is misleading - it may be hash, but
45 * that implementation detail is outside our purview.
51 * Selected/preferred email address of the intended recipient.
56 * The full email message to send to this recipient (per alterMailParams).
60 * @see \CRM_Utils_Hook::alterMailParams()
62 private $mailParams = array();
65 * FlexMailerTask constructor.
67 * @param int $eventQueueId
68 * A persistent record for this email delivery.
69 * @param int $contactId
70 * The ID of the recipiient.
72 * An authentication code.
73 * @param string $address
74 * Selected/preferred email address of the intended recipient.
76 public function __construct(
82 $this->eventQueueId
= $eventQueueId;
83 $this->contactId
= $contactId;
85 $this->address
= $address;
90 * @see \CRM_Mailing_Event_DAO_Queue
92 public function getEventQueueId() {
93 return $this->eventQueueId
;
98 * The ID of the recipiient.
99 * @see \CRM_Contact_DAO_Contact
101 public function getContactId() {
102 return $this->contactId
;
107 * An authentication code. The name is misleading - it may be hash, but
108 * that implementation detail is outside our purview.
110 public function getHash() {
116 * Selected email address of the intended recipient.
118 public function getAddress() {
119 return $this->address
;
125 public function hasContent() {
126 return !empty($this->mailParams
['html']) ||
!empty($this->mailParams
['text']);
131 * @see CRM_Utils_Hook::alterMailParams
133 public function getMailParams() {
134 return $this->mailParams
;
138 * @param \array $mailParams
139 * @return FlexMailerTask
140 * @see CRM_Utils_Hook::alterMailParams
142 public function setMailParams($mailParams) {
143 $this->mailParams
= $mailParams;
149 * @param string $value
151 * @see CRM_Utils_Hook::alterMailParams
153 public function setMailParam($key, $value) {
154 $this->mailParams
[$key] = $value;
161 * @see CRM_Utils_Hook::alterMailParams
163 public function getMailParam($key) {
164 return isset($this->mailParams
[$key]) ?
$this->mailParams
[$key] : NULL;