diff --git a/CRM/Mailing/BAO/MailingJob.php b/CRM/Mailing/BAO/MailingJob.php index f9982a490f6d..97398d7b8108 100644 --- a/CRM/Mailing/BAO/MailingJob.php +++ b/CRM/Mailing/BAO/MailingJob.php @@ -193,7 +193,12 @@ public static function runJobs($testParams = NULL, $mode = NULL) { } // Compose and deliver each child job - $isComplete = $job->deliver($mailer, $testParams); + if (\CRM_Utils_Constant::value('CIVICRM_FLEXMAILER_HACK_DELIVER')) { + $isComplete = Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_DELIVER, array($job, $mailer, $testParams)); + } + else { + $isComplete = $job->deliver($mailer, $testParams); + } CRM_Utils_Hook::post('create', 'CRM_Mailing_DAO_Spool', $job->id, $isComplete); @@ -483,6 +488,10 @@ public function queue($testParams = NULL) { * @return void */ public function deliver(&$mailer, $testParams = NULL) { + if (\Civi::settings()->get('experimentalFlexMailerEngine')) { + throw new \RuntimeException("Cannot use legacy deliver() when experimentalFlexMailerEngine is enabled"); + } + $mailing = new CRM_Mailing_BAO_Mailing(); $mailing->id = $this->mailing_id; $mailing->find(TRUE); diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 33b858c13975..37049ed19284 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -128,6 +128,10 @@ public function createContainer() { "CRM_Mailing_Tokens" ));//->addTag('kernel.event_subscriber'); + if (\CRM_Utils_Constant::value('CIVICRM_FLEXMAILER_HACK_SERVICES')) { + \Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_SERVICES, array($container)); + } + return $container; } @@ -162,6 +166,10 @@ public function createEventDispatcher($container) { $dispatcher->addSubscriberService('crm_mailing_tokens', 'CRM_Mailing_Tokens'); $dispatcher->addSubscriberService('crm_mailing_action_tokens', 'CRM_Mailing_ActionTokens'); + if (\CRM_Utils_Constant::value('CIVICRM_FLEXMAILER_HACK_LISTENERS')) { + \Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_LISTENERS, array($dispatcher)); + } + return $dispatcher; }