Hide feature behind feature flag

[MAILPOET-2307]
This commit is contained in:
Pavel Dohnal
2019-09-04 13:32:35 +02:00
committed by Jack Kitterhing
parent aa1b9157a4
commit 72c62ba937
2 changed files with 16 additions and 2 deletions

View File

@ -7,11 +7,13 @@ class FeaturesController {
// Define features below in the following form:
// const FEATURE_NAME_OF_FEATURE = 'name-of-feature';
const NEW_DEFAULT_LIST_NAME = 'new-default-list-name';
const SEND_WORDPRESS_MAILS_WITH_MP3 = 'send-wordpress-mails-with-mp3';
// Define feature defaults in the array below in the following form:
// self::FEATURE_NAME_OF_FEATURE => true,
private $defaults = [
self::NEW_DEFAULT_LIST_NAME => false,
self::SEND_WORDPRESS_MAILS_WITH_MP3 => false,
];
/** @var array */

View File

@ -2,12 +2,24 @@
namespace MailPoet\Mailer\WordPress;
use MailPoet\Features\FeaturesController;
class WordpressMailerReplacer {
/** @var FeaturesController */
private $features_controller;
function __construct(FeaturesController $features_controller) {
$this->features_controller = $features_controller;
}
public function replaceWordPressMailer() {
global $phpmailer;
return $this->replaceWithCustomPhpMailer($phpmailer);
if ($this->features_controller->isSupported(FeaturesController::SEND_WORDPRESS_MAILS_WITH_MP3)) {
return $this->replaceWithCustomPhpMailer($phpmailer);
}
return $phpmailer;
}
private function replaceWithCustomPhpMailer(&$obj = null) {