sms_provider_id) { return FALSE; } // Use FlexMailer for new-style email blasts (with custom `template_type`). if ($mailing->template_type && $mailing->template_type !== 'traditional') { return TRUE; } switch (\Civi::settings()->get('flexmailer_traditional')) { case 'auto': // Transitional support for old hidden setting "experimentalFlexMailerEngine" (bool) // TODO: Remove this. Maybe after Q4 2019. // TODO: Change this to default to flexmailer return (bool) \Civi::settings()->get('experimentalFlexMailerEngine'); case 'bao': return FALSE; case 'flexmailer': return TRUE; default: throw new \RuntimeException("Unrecognized value for setting 'flexmailer_traditional'"); } } /** * Abdicate; defer to the old system during delivery. * * @param \Civi\FlexMailer\Event\RunEvent $e */ public function onRun(RunEvent $e) { if (self::isFlexmailPreferred($e->getMailing())) { // OK, we'll continue running. return; } // Nope, we'll abdicate. $e->stopPropagation(); $isDelivered = $e->getJob()->deliver( $e->context['deprecatedMessageMailer'], $e->context['deprecatedTestParams'] ); $e->setCompleted($isDelivered); } /** * Abdicate; defer to the old system when checking completeness. * * @param \Civi\FlexMailer\Event\CheckSendableEvent $e */ public function onCheckSendable($e) { if (self::isFlexmailPreferred($e->getMailing())) { // OK, we'll continue running. return; } $e->stopPropagation(); $errors = \CRM_Mailing_BAO_Mailing::checkSendable($e->getMailing()); if (is_array($errors)) { foreach ($errors as $key => $message) { $e->setError($key, $message);; } } } }