Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Change internal references from 'experimentalFlexMailerEngine' to 'fl…
Browse files Browse the repository at this point in the history
…exmailer_traditional'
  • Loading branch information
totten committed Apr 30, 2019
1 parent 7d545f1 commit 78bb0bb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
25 changes: 18 additions & 7 deletions src/Listener/Abdicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,30 @@ class Abdicator {
* @return bool
*/
public static function isFlexmailPreferred($mailing) {
// Hidden setting: "experimentalFlexMailerEngine" (bool)
// If TRUE, we will always use FlexMailer's events.
// Otherwise, we'll generally abdicate.
if (\CRM_Core_BAO_Setting::getItem('Mailing Preferences', 'experimentalFlexMailerEngine')) {
return TRUE;
if ($mailing->sms_provider_id) {
return FALSE;
}

// Use FlexMailer for new-style email blasts (with custom `template_type`).
if ($mailing->template_type && $mailing->template_type !== 'traditional' && !$mailing->sms_provider_id) {
if ($mailing->template_type && $mailing->template_type !== 'traditional') {
return TRUE;
}

return FALSE;
switch (\Civi::settings()->get('flexmailer_traditional')) {
case 'auto':
// Transitional support for old hidden setting "experimentalFlexMailerEngine" (bool)
// TODO: Remove this. Maybe after Q4 2019.
return (bool) \CRM_Core_BAO_Setting::getItem('Mailing Preferences', 'experimentalFlexMailerEngine');

case 'bao':
return FALSE;

case 'flexmailer':
return TRUE;

default:
throw new \RuntimeException("Unrecognized value for setting 'flexmailer_traditional'");
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/Civi/FlexMailer/ConcurrentDeliveryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public function setUp() {

parent::setUp();

\CRM_Core_BAO_Setting::setItem(TRUE, 'Mailing Preferences', 'experimentalFlexMailerEngine');
\Civi::settings()->set('flexmailer_traditional', 'flexmailer');
}

public function tearDown() {
// We're building on someone else's test and don't fully trust them to
// protect our settings. Make sure they did.
$ok = (TRUE == \CRM_Core_BAO_Setting::getItem('Mailing Preferences', 'experimentalFlexMailerEngine'))
&& ('b:1;' === \CRM_Core_DAO::singleValueQuery('SELECT value FROM civicrm_setting WHERE name ="experimentalFlexMailerEngine"'));
$ok = ('flexmailer' == \Civi::settings()->get('flexmailer_traditional'))
&& ('s:10:"flexmailer";' === \CRM_Core_DAO::singleValueQuery('SELECT value FROM civicrm_setting WHERE name ="flexmailer_traditional"'));

parent::tearDown();

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Civi/FlexMailer/FlexMailerSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function setUp() {
}

parent::setUp();
\CRM_Core_BAO_Setting::setItem(TRUE, 'Mailing Preferences', 'experimentalFlexMailerEngine');
\Civi::settings()->set('flexmailer_traditional', 'flexmailer');

$dispatcher = \Civi::service('dispatcher');
foreach (FlexMailer::getEventTypes() as $event => $class) {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Civi/FlexMailer/MailingPreviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setUp() {

parent::setUp();

\CRM_Core_BAO_Setting::setItem(TRUE, 'Mailing Preferences', 'experimentalFlexMailerEngine');
\Civi::settings()->set('flexmailer_traditional', 'flexmailer');

$this->useTransaction();
\CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Civi/FlexMailer/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function setUp() {
}

parent::setUp();
\CRM_Core_BAO_Setting::setItem(TRUE, 'Mailing Preferences', 'experimentalFlexMailerEngine');
\Civi::settings()->set('flexmailer_traditional', 'flexmailer');
}

public function getExamples() {
Expand Down

0 comments on commit 78bb0bb

Please sign in to comment.