Commit | Line | Data |
---|---|---|
bdf67e28 SL |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
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 | +--------------------------------------------------------------------+ | |
10 | */ | |
11 | namespace Civi\FlexMailer\Listener; | |
12 | ||
13 | use Civi\FlexMailer\Event\ComposeBatchEvent; | |
14 | ||
15 | class HookAdapter extends BaseListener { | |
16 | ||
17 | /** | |
18 | * Expose to hook_civicrm_alterMailParams. | |
19 | * | |
20 | * @param \Civi\FlexMailer\Event\ComposeBatchEvent $e | |
21 | */ | |
22 | public function onCompose(ComposeBatchEvent $e) { | |
23 | if (!$this->isActive()) { | |
24 | return; | |
25 | } | |
26 | ||
27 | foreach ($e->getTasks() as $task) { | |
28 | /** @var \Civi\FlexMailer\FlexMailerTask $task */ | |
29 | $mailParams = $task->getMailParams(); | |
30 | if ($mailParams) { | |
31 | \CRM_Utils_Hook::alterMailParams($mailParams, 'flexmailer'); | |
32 | $task->setMailParams($mailParams); | |
33 | } | |
34 | } | |
35 | } | |
36 | ||
37 | } |