-
-
Notifications
You must be signed in to change notification settings - Fork 817
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CRM-19690 - Implement FlexMailer. Add tests.
- Loading branch information
Showing
20 changed files
with
1,960 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| CiviCRM version 4.7 | | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC (c) 2004-2016 | | ||
+--------------------------------------------------------------------+ | ||
| This file is a part of CiviCRM. | | ||
| | | ||
| CiviCRM is free software; you can copy, modify, and distribute it | | ||
| under the terms of the GNU Affero General Public License | | ||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | ||
| | | ||
| CiviCRM is distributed in the hope that it will be useful, but | | ||
| WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | ||
| See the GNU Affero General Public License for more details. | | ||
| | | ||
| You should have received a copy of the GNU Affero General Public | | ||
| License and the CiviCRM Licensing Exception along | | ||
| with this program; if not, contact CiviCRM LLC | | ||
| at info[AT]civicrm[DOT]org. If you have questions about the | | ||
| GNU Affero General Public License or the licensing of CiviCRM, | | ||
| see the CiviCRM license FAQ at http://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
namespace Civi\FlexMailer\Event; | ||
|
||
/** | ||
* Class AlterBatchEvent | ||
* @package Civi\FlexMailer\Event | ||
*/ | ||
class AlterBatchEvent extends BaseEvent { | ||
|
||
/** | ||
* @var array<FlexMailerTask> | ||
*/ | ||
private $tasks; | ||
|
||
public function __construct($context, $tasks) { | ||
parent::__construct($context); | ||
$this->tasks = $tasks; | ||
} | ||
|
||
/** | ||
* @return array<FlexMailerTask> | ||
*/ | ||
public function getTasks() { | ||
return $this->tasks; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| CiviCRM version 4.7 | | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC (c) 2004-2016 | | ||
+--------------------------------------------------------------------+ | ||
| This file is a part of CiviCRM. | | ||
| | | ||
| CiviCRM is free software; you can copy, modify, and distribute it | | ||
| under the terms of the GNU Affero General Public License | | ||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | ||
| | | ||
| CiviCRM is distributed in the hope that it will be useful, but | | ||
| WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | ||
| See the GNU Affero General Public License for more details. | | ||
| | | ||
| You should have received a copy of the GNU Affero General Public | | ||
| License and the CiviCRM Licensing Exception along | | ||
| with this program; if not, contact CiviCRM LLC | | ||
| at info[AT]civicrm[DOT]org. If you have questions about the | | ||
| GNU Affero General Public License or the licensing of CiviCRM, | | ||
| see the CiviCRM license FAQ at http://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
namespace Civi\FlexMailer\Event; | ||
|
||
/** | ||
* Class BaseEvent | ||
* @package Civi\FlexMailer\Event | ||
*/ | ||
class BaseEvent extends \Symfony\Component\EventDispatcher\Event { | ||
/** | ||
* @var array | ||
* An array which must define options: | ||
* - mailing: \CRM_Mailing_BAO_Mailing | ||
* - job: \CRM_Mailing_BAO_MailingJob | ||
* - attachments: array | ||
*/ | ||
public $context; | ||
|
||
/** | ||
* BaseEvent constructor. | ||
* @param array $context | ||
*/ | ||
public function __construct(array $context) { | ||
$this->context = $context; | ||
} | ||
|
||
/** | ||
* @return \CRM_Mailing_BAO_Mailing | ||
*/ | ||
public function getMailing() { | ||
return $this->context['mailing']; | ||
} | ||
|
||
/** | ||
* @return \CRM_Mailing_BAO_MailingJob | ||
*/ | ||
public function getJob() { | ||
return $this->context['job']; | ||
} | ||
|
||
/** | ||
* @return array|NULL | ||
*/ | ||
public function getAttachments() { | ||
return $this->context['attachments']; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| CiviCRM version 4.7 | | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC (c) 2004-2016 | | ||
+--------------------------------------------------------------------+ | ||
| This file is a part of CiviCRM. | | ||
| | | ||
| CiviCRM is free software; you can copy, modify, and distribute it | | ||
| under the terms of the GNU Affero General Public License | | ||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | ||
| | | ||
| CiviCRM is distributed in the hope that it will be useful, but | | ||
| WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | ||
| See the GNU Affero General Public License for more details. | | ||
| | | ||
| You should have received a copy of the GNU Affero General Public | | ||
| License and the CiviCRM Licensing Exception along | | ||
| with this program; if not, contact CiviCRM LLC | | ||
| at info[AT]civicrm[DOT]org. If you have questions about the | | ||
| GNU Affero General Public License or the licensing of CiviCRM, | | ||
| see the CiviCRM license FAQ at http://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
namespace Civi\FlexMailer\Event; | ||
|
||
/** | ||
* Class ComposeBatchEvent | ||
* @package Civi\FlexMailer\Event | ||
*/ | ||
class ComposeBatchEvent extends BaseEvent { | ||
|
||
/** | ||
* @var array<FlexMailerTask> | ||
*/ | ||
private $tasks; | ||
|
||
public function __construct($context, $tasks) { | ||
parent::__construct($context); | ||
$this->tasks = $tasks; | ||
} | ||
|
||
/** | ||
* @return array<FlexMailerTask> | ||
*/ | ||
public function getTasks() { | ||
return $this->tasks; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| CiviCRM version 4.7 | | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC (c) 2004-2016 | | ||
+--------------------------------------------------------------------+ | ||
| This file is a part of CiviCRM. | | ||
| | | ||
| CiviCRM is free software; you can copy, modify, and distribute it | | ||
| under the terms of the GNU Affero General Public License | | ||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | ||
| | | ||
| CiviCRM is distributed in the hope that it will be useful, but | | ||
| WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | ||
| See the GNU Affero General Public License for more details. | | ||
| | | ||
| You should have received a copy of the GNU Affero General Public | | ||
| License and the CiviCRM Licensing Exception along | | ||
| with this program; if not, contact CiviCRM LLC | | ||
| at info[AT]civicrm[DOT]org. If you have questions about the | | ||
| GNU Affero General Public License or the licensing of CiviCRM, | | ||
| see the CiviCRM license FAQ at http://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
namespace Civi\FlexMailer\Event; | ||
|
||
/** | ||
* Class RunEvent | ||
* @package Civi\FlexMailer\Event | ||
* | ||
* The RunEvent fires at the start of mail delivery process. | ||
* | ||
* You may use this event to either: | ||
* - Perform extra initialization at the start of the process. | ||
* - Short-circuit the entire process. In this use-case, be | ||
* sure to run `$event->stopPropagation()` | ||
* and `$event->setCompleted($bool)`. | ||
*/ | ||
class RunEvent extends BaseEvent { | ||
|
||
/** | ||
* @var bool|NULL | ||
*/ | ||
private $isCompleted = NULL; | ||
|
||
/** | ||
* @return bool|NULL | ||
*/ | ||
public function getCompleted() { | ||
return $this->isCompleted; | ||
} | ||
|
||
/** | ||
* @param bool|NULL $isCompleted | ||
* @return RunEvent | ||
*/ | ||
public function setCompleted($isCompleted) { | ||
$this->isCompleted = $isCompleted; | ||
return $this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| CiviCRM version 4.7 | | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC (c) 2004-2016 | | ||
+--------------------------------------------------------------------+ | ||
| This file is a part of CiviCRM. | | ||
| | | ||
| CiviCRM is free software; you can copy, modify, and distribute it | | ||
| under the terms of the GNU Affero General Public License | | ||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | ||
| | | ||
| CiviCRM is distributed in the hope that it will be useful, but | | ||
| WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | ||
| See the GNU Affero General Public License for more details. | | ||
| | | ||
| You should have received a copy of the GNU Affero General Public | | ||
| License and the CiviCRM Licensing Exception along | | ||
| with this program; if not, contact CiviCRM LLC | | ||
| at info[AT]civicrm[DOT]org. If you have questions about the | | ||
| GNU Affero General Public License or the licensing of CiviCRM, | | ||
| see the CiviCRM license FAQ at http://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
namespace Civi\FlexMailer\Event; | ||
|
||
/** | ||
* Class SendBatchEvent | ||
* @package Civi\FlexMailer\Event | ||
*/ | ||
class SendBatchEvent extends BaseEvent { | ||
|
||
/** | ||
* @var array<FlexMailerTask> | ||
*/ | ||
private $tasks; | ||
|
||
/** | ||
* @var bool|NULL | ||
*/ | ||
private $isCompleted = NULL; | ||
|
||
public function __construct($context, $tasks) { | ||
parent::__construct($context); | ||
$this->tasks = $tasks; | ||
} | ||
|
||
/** | ||
* @return array<FlexMailerTask> | ||
*/ | ||
public function getTasks() { | ||
return $this->tasks; | ||
} | ||
|
||
/** | ||
* @return bool|NULL | ||
*/ | ||
public function getCompleted() { | ||
return $this->isCompleted; | ||
} | ||
|
||
/** | ||
* @param bool|NULL $isCompleted | ||
* @return SendBatchEvent | ||
*/ | ||
public function setCompleted($isCompleted) { | ||
$this->isCompleted = $isCompleted; | ||
return $this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| CiviCRM version 4.7 | | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC (c) 2004-2016 | | ||
+--------------------------------------------------------------------+ | ||
| This file is a part of CiviCRM. | | ||
| | | ||
| CiviCRM is free software; you can copy, modify, and distribute it | | ||
| under the terms of the GNU Affero General Public License | | ||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | ||
| | | ||
| CiviCRM is distributed in the hope that it will be useful, but | | ||
| WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | ||
| See the GNU Affero General Public License for more details. | | ||
| | | ||
| You should have received a copy of the GNU Affero General Public | | ||
| License and the CiviCRM Licensing Exception along | | ||
| with this program; if not, contact CiviCRM LLC | | ||
| at info[AT]civicrm[DOT]org. If you have questions about the | | ||
| GNU Affero General Public License or the licensing of CiviCRM, | | ||
| see the CiviCRM license FAQ at http://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
namespace Civi\FlexMailer\Event; | ||
|
||
/** | ||
* Class WalkBatchesEvent | ||
* @package Civi\FlexMailer\Event | ||
*/ | ||
class WalkBatchesEvent extends BaseEvent { | ||
|
||
/** | ||
* @var callable | ||
*/ | ||
protected $callback; | ||
|
||
/** | ||
* @var bool|NULL | ||
*/ | ||
protected $isDelivered = NULL; | ||
|
||
public function __construct($context, $callback) { | ||
parent::__construct($context); | ||
$this->callback = $callback; | ||
} | ||
|
||
/** | ||
* @return bool|NULL | ||
*/ | ||
public function getCompleted() { | ||
return $this->isDelivered; | ||
} | ||
|
||
/** | ||
* @param bool|NULL $isCompleted | ||
* @return WalkBatchesEvent | ||
*/ | ||
public function setCompleted($isCompleted) { | ||
$this->isDelivered = $isCompleted; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param array <FlexMailerTask> $tasks | ||
* @return mixed | ||
*/ | ||
public function visit($tasks) { | ||
return call_user_func($this->callback, $tasks); | ||
} | ||
|
||
} |
Oops, something went wrong.