Add public keyword to methods
[MAILPOET-2413]
This commit is contained in:
@ -32,14 +32,14 @@ class Mailer {
|
||||
const METHOD_PHPMAIL = 'PHPMail';
|
||||
const METHOD_SMTP = 'SMTP';
|
||||
|
||||
function __construct(SettingsController $settings = null) {
|
||||
public function __construct(SettingsController $settings = null) {
|
||||
if (!$settings) {
|
||||
$settings = SettingsController::getInstance();
|
||||
}
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
function init($mailer = false, $sender = false, $reply_to = false, $return_path = false) {
|
||||
public function init($mailer = false, $sender = false, $reply_to = false, $return_path = false) {
|
||||
$this->mailer_config = $this->getMailerConfig($mailer);
|
||||
$this->sender = $this->getSenderNameAndAddress($sender);
|
||||
$this->reply_to = $this->getReplyToNameAndAddress($reply_to);
|
||||
@ -47,7 +47,7 @@ class Mailer {
|
||||
$this->mailer_instance = $this->buildMailer();
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
public function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if (!$this->mailer_instance) {
|
||||
$this->init();
|
||||
}
|
||||
@ -134,7 +134,7 @@ class Mailer {
|
||||
];
|
||||
}
|
||||
|
||||
function getReplyToNameAndAddress($reply_to = []) {
|
||||
public function getReplyToNameAndAddress($reply_to = []) {
|
||||
if (!$reply_to) {
|
||||
$reply_to = $this->settings->get('reply_to');
|
||||
$reply_to['name'] = (!empty($reply_to['name'])) ?
|
||||
@ -155,7 +155,7 @@ class Mailer {
|
||||
];
|
||||
}
|
||||
|
||||
function getReturnPathAddress($return_path) {
|
||||
public function getReturnPathAddress($return_path) {
|
||||
return ($return_path) ?
|
||||
$return_path :
|
||||
$this->settings->get('bounce.address');
|
||||
@ -164,7 +164,7 @@ class Mailer {
|
||||
/**
|
||||
* @param \MailPoet\Models\Subscriber|array $subscriber
|
||||
*/
|
||||
function formatSubscriberNameAndEmailAddress($subscriber) {
|
||||
public function formatSubscriberNameAndEmailAddress($subscriber) {
|
||||
$subscriber = (is_object($subscriber)) ? $subscriber->asArray() : $subscriber;
|
||||
if (!is_array($subscriber)) return $subscriber;
|
||||
if (isset($subscriber['address'])) $subscriber['email'] = $subscriber['address'];
|
||||
@ -183,20 +183,20 @@ class Mailer {
|
||||
return $subscriber;
|
||||
}
|
||||
|
||||
function encodeAddressNamePart($name) {
|
||||
public function encodeAddressNamePart($name) {
|
||||
if (mb_detect_encoding($name) === 'ASCII') return $name;
|
||||
// encode non-ASCII string as per RFC 2047 (https://www.ietf.org/rfc/rfc2047.txt)
|
||||
return sprintf('=?utf-8?B?%s?=', base64_encode($name));
|
||||
}
|
||||
|
||||
static function formatMailerErrorResult(MailerError $error) {
|
||||
public static function formatMailerErrorResult(MailerError $error) {
|
||||
return [
|
||||
'response' => false,
|
||||
'error' => $error,
|
||||
];
|
||||
}
|
||||
|
||||
static function formatMailerSendSuccessResult() {
|
||||
public static function formatMailerSendSuccessResult() {
|
||||
return [
|
||||
'response' => true,
|
||||
];
|
||||
|
@ -36,7 +36,7 @@ class MailerError {
|
||||
* @param int|null $retry_interval
|
||||
* @param array $subscribers_errors
|
||||
*/
|
||||
function __construct($operation, $level, $message = null, $retry_interval = null, array $subscribers_errors = []) {
|
||||
public function __construct($operation, $level, $message = null, $retry_interval = null, array $subscribers_errors = []) {
|
||||
$this->operation = $operation;
|
||||
$this->level = $level;
|
||||
$this->message = $message;
|
||||
@ -47,39 +47,39 @@ class MailerError {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getOperation() {
|
||||
public function getOperation() {
|
||||
return $this->operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getLevel() {
|
||||
public function getLevel() {
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
function getMessage() {
|
||||
public function getMessage() {
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
function getRetryInterval() {
|
||||
public function getRetryInterval() {
|
||||
return $this->retry_interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SubscriberError[]
|
||||
*/
|
||||
function getSubscriberErrors() {
|
||||
public function getSubscriberErrors() {
|
||||
return $this->subscribers_errors;
|
||||
}
|
||||
|
||||
function getMessageWithFailedSubscribers() {
|
||||
public function getMessageWithFailedSubscribers() {
|
||||
$message = $this->message ?: '';
|
||||
if (!$this->subscribers_errors) {
|
||||
return $message;
|
||||
|
@ -10,7 +10,7 @@ class MailerLog {
|
||||
const RETRY_ATTEMPTS_LIMIT = 3;
|
||||
const RETRY_INTERVAL = 120; // seconds
|
||||
|
||||
static function getMailerLog($mailer_log = false) {
|
||||
public static function getMailerLog($mailer_log = false) {
|
||||
if ($mailer_log) return $mailer_log;
|
||||
$settings = SettingsController::getInstance();
|
||||
$mailer_log = $settings->get(self::SETTING_NAME);
|
||||
@ -20,7 +20,7 @@ class MailerLog {
|
||||
return $mailer_log;
|
||||
}
|
||||
|
||||
static function createMailerLog() {
|
||||
public static function createMailerLog() {
|
||||
$mailer_log = [
|
||||
'sent' => null,
|
||||
'started' => time(),
|
||||
@ -34,17 +34,17 @@ class MailerLog {
|
||||
return $mailer_log;
|
||||
}
|
||||
|
||||
static function resetMailerLog() {
|
||||
public static function resetMailerLog() {
|
||||
return self::createMailerLog();
|
||||
}
|
||||
|
||||
static function updateMailerLog($mailer_log) {
|
||||
public static function updateMailerLog($mailer_log) {
|
||||
$settings = SettingsController::getInstance();
|
||||
$settings->set(self::SETTING_NAME, $mailer_log);
|
||||
return $mailer_log;
|
||||
}
|
||||
|
||||
static function enforceExecutionRequirements($mailer_log = false) {
|
||||
public static function enforceExecutionRequirements($mailer_log = false) {
|
||||
$mailer_log = self::getMailerLog($mailer_log);
|
||||
if ($mailer_log['retry_attempt'] === self::RETRY_ATTEMPTS_LIMIT) {
|
||||
$mailer_log = self::pauseSending($mailer_log);
|
||||
@ -66,14 +66,14 @@ class MailerLog {
|
||||
}
|
||||
}
|
||||
|
||||
static function pauseSending($mailer_log) {
|
||||
public static function pauseSending($mailer_log) {
|
||||
$mailer_log['status'] = self::STATUS_PAUSED;
|
||||
$mailer_log['retry_attempt'] = null;
|
||||
$mailer_log['retry_at'] = null;
|
||||
return self::updateMailerLog($mailer_log);
|
||||
}
|
||||
|
||||
static function resumeSending() {
|
||||
public static function resumeSending() {
|
||||
return self::resetMailerLog();
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class MailerLog {
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
static function processNonBlockingError($operation, $error_message, $retry_interval = self::RETRY_INTERVAL) {
|
||||
public static function processNonBlockingError($operation, $error_message, $retry_interval = self::RETRY_INTERVAL) {
|
||||
$mailer_log = self::getMailerLog();
|
||||
$mailer_log['retry_at'] = time() + $retry_interval;
|
||||
$mailer_log = self::setError($mailer_log, $operation, $error_message);
|
||||
@ -104,7 +104,7 @@ class MailerLog {
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
static function processError($operation, $error_message, $error_code = null, $pause_sending = false) {
|
||||
public static function processError($operation, $error_message, $error_code = null, $pause_sending = false) {
|
||||
$mailer_log = self::getMailerLog();
|
||||
$mailer_log['retry_attempt']++;
|
||||
$mailer_log['retry_at'] = time() + self::RETRY_INTERVAL;
|
||||
@ -116,7 +116,7 @@ class MailerLog {
|
||||
self::enforceExecutionRequirements();
|
||||
}
|
||||
|
||||
static function setError($mailer_log, $operation, $error_message, $error_code = null) {
|
||||
public static function setError($mailer_log, $operation, $error_message, $error_code = null) {
|
||||
$mailer_log['error'] = [
|
||||
'operation' => $operation,
|
||||
'error_message' => $error_message,
|
||||
@ -127,12 +127,12 @@ class MailerLog {
|
||||
return $mailer_log;
|
||||
}
|
||||
|
||||
static function getError($mailer_log = false) {
|
||||
public static function getError($mailer_log = false) {
|
||||
$mailer_log = self::getMailerLog($mailer_log);
|
||||
return isset($mailer_log['error']) ? $mailer_log['error'] : null;
|
||||
}
|
||||
|
||||
static function incrementSentCount() {
|
||||
public static function incrementSentCount() {
|
||||
$mailer_log = self::getMailerLog();
|
||||
// do not increment count if sending limit is reached
|
||||
if (self::isSendingLimitReached($mailer_log)) return;
|
||||
@ -144,14 +144,14 @@ class MailerLog {
|
||||
return self::updateMailerLog($mailer_log);
|
||||
}
|
||||
|
||||
static function clearSendingErrorLog($mailer_log) {
|
||||
public static function clearSendingErrorLog($mailer_log) {
|
||||
$mailer_log['retry_attempt'] = null;
|
||||
$mailer_log['retry_at'] = null;
|
||||
$mailer_log['error'] = null;
|
||||
return self::updateMailerLog($mailer_log);
|
||||
}
|
||||
|
||||
static function isSendingLimitReached($mailer_log = false) {
|
||||
public static function isSendingLimitReached($mailer_log = false) {
|
||||
$settings = SettingsController::getInstance();
|
||||
$mailer_config = $settings->get(Mailer::MAILER_CONFIG_SETTING_NAME);
|
||||
// do not enforce sending limit for MailPoet's sending method
|
||||
@ -174,7 +174,7 @@ class MailerLog {
|
||||
return false;
|
||||
}
|
||||
|
||||
static function isSendingPaused($mailer_log = false) {
|
||||
public static function isSendingPaused($mailer_log = false) {
|
||||
$mailer_log = self::getMailerLog($mailer_log);
|
||||
return $mailer_log['status'] === self::STATUS_PAUSED;
|
||||
}
|
||||
|
@ -7,19 +7,19 @@ use MailPoet\Models\Newsletter;
|
||||
use MailPoet\Models\Subscriber;
|
||||
|
||||
class MetaInfo {
|
||||
function getSendingTestMetaInfo() {
|
||||
public function getSendingTestMetaInfo() {
|
||||
return $this->makeMetaInfo('sending_test', 'unknown', 'administrator');
|
||||
}
|
||||
|
||||
function getPreviewMetaInfo() {
|
||||
public function getPreviewMetaInfo() {
|
||||
return $this->makeMetaInfo('preview', 'unknown', 'administrator');
|
||||
}
|
||||
|
||||
function getStatsNotificationMetaInfo() {
|
||||
public function getStatsNotificationMetaInfo() {
|
||||
return $this->makeMetaInfo('email_stats_notification', 'unknown', 'administrator');
|
||||
}
|
||||
|
||||
function getWordPressTransactionalMetaInfo(SubscriberEntity $subscriber = null) {
|
||||
public function getWordPressTransactionalMetaInfo(SubscriberEntity $subscriber = null) {
|
||||
return $this->makeMetaInfo(
|
||||
'transactional',
|
||||
$subscriber ? $subscriber->getStatus() : 'unknown',
|
||||
@ -27,15 +27,15 @@ class MetaInfo {
|
||||
);
|
||||
}
|
||||
|
||||
function getConfirmationMetaInfo(Subscriber $subscriber) {
|
||||
public function getConfirmationMetaInfo(Subscriber $subscriber) {
|
||||
return $this->makeMetaInfo('confirmation', $subscriber->status, $subscriber->source);
|
||||
}
|
||||
|
||||
function getNewSubscriberNotificationMetaInfo() {
|
||||
public function getNewSubscriberNotificationMetaInfo() {
|
||||
return $this->makeMetaInfo('new_subscriber_notification', 'unknown', 'administrator');
|
||||
}
|
||||
|
||||
function getNewsletterMetaInfo($newsletter, Subscriber $subscriber) {
|
||||
public function getNewsletterMetaInfo($newsletter, Subscriber $subscriber) {
|
||||
$type = 'unknown';
|
||||
switch ($newsletter->type) {
|
||||
case Newsletter::TYPE_AUTOMATIC:
|
||||
|
@ -38,7 +38,7 @@ class AmazonSES {
|
||||
|
||||
private $wp;
|
||||
|
||||
function __construct(
|
||||
public function __construct(
|
||||
$region,
|
||||
$access_key,
|
||||
$secret_key,
|
||||
@ -71,7 +71,7 @@ class AmazonSES {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
public function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
@ -97,7 +97,7 @@ class AmazonSES {
|
||||
return Mailer::formatMailerSendSuccessResult();
|
||||
}
|
||||
|
||||
function getBody($newsletter, $subscriber, $extra_params = []) {
|
||||
public function getBody($newsletter, $subscriber, $extra_params = []) {
|
||||
$this->message = $this->createMessage($newsletter, $subscriber, $extra_params);
|
||||
$body = [
|
||||
'Action' => 'SendRawEmail',
|
||||
@ -108,7 +108,7 @@ class AmazonSES {
|
||||
return $body;
|
||||
}
|
||||
|
||||
function createMessage($newsletter, $subscriber, $extra_params = []) {
|
||||
public function createMessage($newsletter, $subscriber, $extra_params = []) {
|
||||
$message = Swift_Message::newInstance()
|
||||
->setTo($this->processSubscriber($subscriber))
|
||||
->setFrom([
|
||||
@ -133,11 +133,11 @@ class AmazonSES {
|
||||
return $message;
|
||||
}
|
||||
|
||||
function encodeMessage(Swift_Message $message) {
|
||||
public function encodeMessage(Swift_Message $message) {
|
||||
return base64_encode($message->toString());
|
||||
}
|
||||
|
||||
function processSubscriber($subscriber) {
|
||||
public function processSubscriber($subscriber) {
|
||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriber_data);
|
||||
if (!isset($subscriber_data['email'])) {
|
||||
$subscriber_data = [
|
||||
@ -150,7 +150,7 @@ class AmazonSES {
|
||||
];
|
||||
}
|
||||
|
||||
function request($newsletter, $subscriber, $extra_params = []) {
|
||||
public function request($newsletter, $subscriber, $extra_params = []) {
|
||||
$body = array_map('urlencode', $this->getBody($newsletter, $subscriber, $extra_params));
|
||||
return [
|
||||
'timeout' => 10,
|
||||
@ -165,7 +165,7 @@ class AmazonSES {
|
||||
];
|
||||
}
|
||||
|
||||
function signRequest($body) {
|
||||
public function signRequest($body) {
|
||||
$string_to_sign = $this->createStringToSign(
|
||||
$this->getCredentialScope(),
|
||||
$this->getCanonicalRequest($body)
|
||||
@ -184,7 +184,7 @@ class AmazonSES {
|
||||
$signature);
|
||||
}
|
||||
|
||||
function getCredentialScope() {
|
||||
public function getCredentialScope() {
|
||||
return sprintf(
|
||||
'%s/%s/%s/%s',
|
||||
$this->date_without_time,
|
||||
@ -193,7 +193,7 @@ class AmazonSES {
|
||||
$this->aws_termination_string);
|
||||
}
|
||||
|
||||
function getCanonicalRequest($body) {
|
||||
public function getCanonicalRequest($body) {
|
||||
return implode("\n", [
|
||||
'POST',
|
||||
'/',
|
||||
@ -206,7 +206,7 @@ class AmazonSES {
|
||||
]);
|
||||
}
|
||||
|
||||
function createStringToSign($credential_scope, $canonical_request) {
|
||||
public function createStringToSign($credential_scope, $canonical_request) {
|
||||
return implode("\n", [
|
||||
$this->aws_signing_algorithm,
|
||||
$this->date,
|
||||
@ -215,7 +215,7 @@ class AmazonSES {
|
||||
]);
|
||||
}
|
||||
|
||||
function getSigningKey() {
|
||||
public function getSigningKey() {
|
||||
$date_key = hash_hmac(
|
||||
$this->hash_algorithm,
|
||||
$this->date_without_time,
|
||||
|
@ -15,7 +15,7 @@ class BlacklistCheck {
|
||||
$this->blacklist = $blacklist;
|
||||
}
|
||||
|
||||
function isBlacklisted($subscriber) {
|
||||
public function isBlacklisted($subscriber) {
|
||||
$email = $this->getSubscriberEmailForBlacklistCheck($subscriber);
|
||||
return $this->blacklist->isBlacklisted($email);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class AmazonSESMapper {
|
||||
|
||||
const METHOD = Mailer::METHOD_AMAZONSES;
|
||||
|
||||
function getErrorFromException(\Exception $e, $subscriber) {
|
||||
public function getErrorFromException(\Exception $e, $subscriber) {
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
if ($e instanceof Swift_RfcComplianceException) {
|
||||
$level = MailerError::LEVEL_SOFT;
|
||||
@ -27,7 +27,7 @@ class AmazonSESMapper {
|
||||
* @see https://docs.aws.amazon.com/ses/latest/DeveloperGuide/api-error-codes.html
|
||||
* @return MailerError
|
||||
*/
|
||||
function getErrorFromResponse($response, $subscriber) {
|
||||
public function getErrorFromResponse($response, $subscriber) {
|
||||
$message = ($response) ?
|
||||
$response->Error->Message->__toString() :
|
||||
sprintf(WPFunctions::get()->__('%s has returned an unknown error.', 'mailpoet'), Mailer::METHOD_AMAZONSES);
|
||||
|
@ -7,7 +7,7 @@ use MailPoet\Mailer\SubscriberError;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
trait BlacklistErrorMapperTrait {
|
||||
function getBlacklistError($subscriber) {
|
||||
public function getBlacklistError($subscriber) {
|
||||
$message = sprintf(WPFunctions::get()->__('%s has returned an unknown error.', 'mailpoet'), self::METHOD);
|
||||
$subscriber_errors = [new SubscriberError($subscriber, null)];
|
||||
return new MailerError(MailerError::OPERATION_SEND, MailerError::LEVEL_SOFT, $message, null, $subscriber_errors);
|
||||
|
@ -5,7 +5,7 @@ namespace MailPoet\Mailer\Methods\ErrorMappers;
|
||||
use MailPoet\Mailer\MailerError;
|
||||
|
||||
trait ConnectionErrorMapperTrait {
|
||||
function getConnectionError($message) {
|
||||
public function getConnectionError($message) {
|
||||
return new MailerError(
|
||||
MailerError::OPERATION_CONNECT,
|
||||
MailerError::LEVEL_HARD,
|
||||
|
@ -18,7 +18,7 @@ class MailPoetMapper {
|
||||
|
||||
const TEMPORARY_UNAVAILABLE_RETRY_INTERVAL = 300; // seconds
|
||||
|
||||
function getInvalidApiKeyError() {
|
||||
public function getInvalidApiKeyError() {
|
||||
return new MailerError(
|
||||
MailerError::OPERATION_SEND,
|
||||
MailerError::LEVEL_HARD,
|
||||
@ -26,7 +26,7 @@ class MailPoetMapper {
|
||||
);
|
||||
}
|
||||
|
||||
function getErrorForResult(array $result, $subscribers, $sender = null, $newsletter = null) {
|
||||
public function getErrorForResult(array $result, $subscribers, $sender = null, $newsletter = null) {
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
$operation = MailerError::OPERATION_SEND;
|
||||
$retry_interval = null;
|
||||
|
@ -13,7 +13,7 @@ class PHPMailMapper {
|
||||
|
||||
const METHOD = Mailer::METHOD_PHPMAIL;
|
||||
|
||||
function getErrorFromException(\Exception $e, $subscriber) {
|
||||
public function getErrorFromException(\Exception $e, $subscriber) {
|
||||
$level = MailerError::LEVEL_HARD;
|
||||
if (strpos($e->getMessage(), 'Invalid address') === 0) {
|
||||
$level = MailerError::LEVEL_SOFT;
|
||||
@ -23,7 +23,7 @@ class PHPMailMapper {
|
||||
return new MailerError(MailerError::OPERATION_SEND, $level, $e->getMessage(), null, $subscriber_errors);
|
||||
}
|
||||
|
||||
function getErrorForSubscriber($subscriber) {
|
||||
public function getErrorForSubscriber($subscriber) {
|
||||
$message = sprintf(WPFunctions::get()->__('%s has returned an unknown error.', 'mailpoet'), Mailer::METHOD_PHPMAIL);
|
||||
$subscriber_errors = [new SubscriberError($subscriber, null)];
|
||||
return new MailerError(MailerError::OPERATION_SEND, MailerError::LEVEL_HARD, $message, null, $subscriber_errors);
|
||||
|
@ -18,7 +18,7 @@ class SMTPMapper {
|
||||
* @see https://swiftmailer.symfony.com/docs/sending.html
|
||||
* @return MailerError
|
||||
*/
|
||||
function getErrorFromException(\Exception $e, $subscriber) {
|
||||
public function getErrorFromException(\Exception $e, $subscriber) {
|
||||
// remove redundant information appended by Swift logger to exception messages
|
||||
$message = explode(PHP_EOL, $e->getMessage());
|
||||
|
||||
@ -30,7 +30,7 @@ class SMTPMapper {
|
||||
return new MailerError(MailerError::OPERATION_SEND, $level, $message[0], null, $subscriber_errors);
|
||||
}
|
||||
|
||||
function getErrorFromLog($log, $subscriber) {
|
||||
public function getErrorFromLog($log, $subscriber) {
|
||||
// extract error message from log
|
||||
preg_match('/!! (.*?)>>/ism', $log, $message);
|
||||
if (!empty($message[1])) {
|
||||
|
@ -13,7 +13,7 @@ class SendGridMapper {
|
||||
|
||||
const METHOD = Mailer::METHOD_SENDGRID;
|
||||
|
||||
function getErrorFromResponse($response, $subscriber) {
|
||||
public function getErrorFromResponse($response, $subscriber) {
|
||||
$response = (!empty($response['errors'][0])) ?
|
||||
$response['errors'][0] :
|
||||
sprintf(WPFunctions::get()->__('%s has returned an unknown error.', 'mailpoet'), Mailer::METHOD_SENDGRID);
|
||||
|
@ -26,7 +26,7 @@ class MailPoet {
|
||||
/** @var BlacklistCheck */
|
||||
private $blacklist;
|
||||
|
||||
function __construct($api_key, $sender, $reply_to, MailPoetMapper $error_mapper, AuthorizedEmailsController $authorized_emails_controller) {
|
||||
public function __construct($api_key, $sender, $reply_to, MailPoetMapper $error_mapper, AuthorizedEmailsController $authorized_emails_controller) {
|
||||
$this->api = new API($api_key);
|
||||
$this->sender = $sender;
|
||||
$this->reply_to = $reply_to;
|
||||
@ -36,7 +36,7 @@ class MailPoet {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
public function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->services_checker->isMailPoetAPIKeyValid() === false) {
|
||||
return Mailer::formatMailerErrorResult($this->error_mapper->getInvalidApiKeyError());
|
||||
}
|
||||
@ -65,7 +65,7 @@ class MailPoet {
|
||||
}
|
||||
}
|
||||
|
||||
function processSendError($result, $subscriber, $newsletter) {
|
||||
public function processSendError($result, $subscriber, $newsletter) {
|
||||
if (!empty($result['code']) && $result['code'] === API::RESPONSE_CODE_KEY_INVALID) {
|
||||
Bridge::invalidateKey();
|
||||
} elseif (!empty($result['code'])
|
||||
@ -77,7 +77,7 @@ class MailPoet {
|
||||
return $this->error_mapper->getErrorForResult($result, $subscriber, $this->sender, $newsletter);
|
||||
}
|
||||
|
||||
function processSubscriber($subscriber) {
|
||||
public function processSubscriber($subscriber) {
|
||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriber_data);
|
||||
if (!isset($subscriber_data['email'])) {
|
||||
$subscriber_data = [
|
||||
@ -90,7 +90,7 @@ class MailPoet {
|
||||
];
|
||||
}
|
||||
|
||||
function getBody($newsletter, $subscriber, $extra_params = []) {
|
||||
public function getBody($newsletter, $subscriber, $extra_params = []) {
|
||||
if (is_array($newsletter) && is_array($subscriber)) {
|
||||
$body = [];
|
||||
for ($record = 0; $record < count($newsletter); $record++) {
|
||||
|
@ -20,7 +20,7 @@ class PHPMail {
|
||||
/** @var BlacklistCheck */
|
||||
private $blacklist;
|
||||
|
||||
function __construct($sender, $reply_to, $return_path, PHPMailMapper $error_mapper) {
|
||||
public function __construct($sender, $reply_to, $return_path, PHPMailMapper $error_mapper) {
|
||||
$this->sender = $sender;
|
||||
$this->reply_to = $reply_to;
|
||||
$this->return_path = ($return_path) ?
|
||||
@ -31,7 +31,7 @@ class PHPMail {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
public function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
@ -50,14 +50,14 @@ class PHPMail {
|
||||
}
|
||||
}
|
||||
|
||||
function buildMailer() {
|
||||
public function buildMailer() {
|
||||
$mailer = new \PHPMailer(true);
|
||||
// send using PHP's mail() function
|
||||
$mailer->isMail();
|
||||
return $mailer;
|
||||
}
|
||||
|
||||
function configureMailerWithMessage($newsletter, $subscriber, $extra_params = []) {
|
||||
public function configureMailerWithMessage($newsletter, $subscriber, $extra_params = []) {
|
||||
$mailer = $this->mailer;
|
||||
$mailer->clearAddresses();
|
||||
$mailer->clearCustomHeaders();
|
||||
@ -91,7 +91,7 @@ class PHPMail {
|
||||
return $mailer;
|
||||
}
|
||||
|
||||
function processSubscriber($subscriber) {
|
||||
public function processSubscriber($subscriber) {
|
||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriber_data);
|
||||
if (!isset($subscriber_data['email'])) {
|
||||
$subscriber_data = [
|
||||
|
@ -34,7 +34,7 @@ class SMTP {
|
||||
|
||||
private $wp;
|
||||
|
||||
function __construct(
|
||||
public function __construct(
|
||||
$host, $port, $authentication, $login = null, $password = null, $encryption,
|
||||
$sender, $reply_to, $return_path, SMTPMapper $error_mapper) {
|
||||
$this->wp = new WPFunctions;
|
||||
@ -56,7 +56,7 @@ class SMTP {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
public function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
@ -77,7 +77,7 @@ class SMTP {
|
||||
}
|
||||
}
|
||||
|
||||
function buildMailer() {
|
||||
public function buildMailer() {
|
||||
$transport = Swift_SmtpTransport::newInstance(
|
||||
$this->host, $this->port, $this->encryption);
|
||||
$connection_timeout = $this->wp->applyFilters('mailpoet_mailer_smtp_connection_timeout', self::SMTP_CONNECTION_TIMEOUT);
|
||||
@ -91,7 +91,7 @@ class SMTP {
|
||||
return Swift_Mailer::newInstance($transport);
|
||||
}
|
||||
|
||||
function createMessage($newsletter, $subscriber, $extra_params = []) {
|
||||
public function createMessage($newsletter, $subscriber, $extra_params = []) {
|
||||
$message = Swift_Message::newInstance()
|
||||
->setTo($this->processSubscriber($subscriber))
|
||||
->setFrom(
|
||||
@ -120,7 +120,7 @@ class SMTP {
|
||||
return $message;
|
||||
}
|
||||
|
||||
function processSubscriber($subscriber) {
|
||||
public function processSubscriber($subscriber) {
|
||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriber_data);
|
||||
if (!isset($subscriber_data['email'])) {
|
||||
$subscriber_data = [
|
||||
|
@ -21,7 +21,7 @@ class SendGrid {
|
||||
|
||||
private $wp;
|
||||
|
||||
function __construct($api_key, $sender, $reply_to, SendGridMapper $error_mapper) {
|
||||
public function __construct($api_key, $sender, $reply_to, SendGridMapper $error_mapper) {
|
||||
$this->api_key = $api_key;
|
||||
$this->sender = $sender;
|
||||
$this->reply_to = $reply_to;
|
||||
@ -30,7 +30,7 @@ class SendGrid {
|
||||
$this->blacklist = new BlacklistCheck();
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = []) {
|
||||
public function send($newsletter, $subscriber, $extra_params = []) {
|
||||
if ($this->blacklist->isBlacklisted($subscriber)) {
|
||||
$error = $this->error_mapper->getBlacklistError($subscriber);
|
||||
return Mailer::formatMailerErrorResult($error);
|
||||
@ -51,7 +51,7 @@ class SendGrid {
|
||||
return Mailer::formatMailerSendSuccessResult();
|
||||
}
|
||||
|
||||
function getBody($newsletter, $subscriber, $extra_params = []) {
|
||||
public function getBody($newsletter, $subscriber, $extra_params = []) {
|
||||
$body = [
|
||||
'to' => $subscriber,
|
||||
'from' => $this->sender['from_email'],
|
||||
@ -75,11 +75,11 @@ class SendGrid {
|
||||
return $body;
|
||||
}
|
||||
|
||||
function auth() {
|
||||
public function auth() {
|
||||
return 'Bearer ' . $this->api_key;
|
||||
}
|
||||
|
||||
function request($newsletter, $subscriber, $extra_params = []) {
|
||||
public function request($newsletter, $subscriber, $extra_params = []) {
|
||||
$body = $this->getBody($newsletter, $subscriber, $extra_params);
|
||||
return [
|
||||
'timeout' => 10,
|
||||
|
@ -14,7 +14,7 @@ class SubscriberError {
|
||||
* @param string $email
|
||||
* @param string $message|null
|
||||
*/
|
||||
function __construct($email, $message = null) {
|
||||
public function __construct($email, $message = null) {
|
||||
$this->email = $email;
|
||||
$this->message = $message;
|
||||
}
|
||||
@ -22,18 +22,18 @@ class SubscriberError {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getEmail() {
|
||||
public function getEmail() {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
function getMessage() {
|
||||
public function getMessage() {
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
function __toString() {
|
||||
public function __toString() {
|
||||
return $this->message ? $this->email . ': ' . $this->message : $this->email;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use MailPoet\Mailer\Mailer;
|
||||
class FallbackMailer extends Mailer {
|
||||
const FALLBACK_METHOD = self::METHOD_PHPMAIL;
|
||||
|
||||
function init($mailer = false, $sender = false, $reply_to = false, $return_path = false) {
|
||||
public function init($mailer = false, $sender = false, $reply_to = false, $return_path = false) {
|
||||
// init is called lazily from when sending, we need to set correct sending method
|
||||
parent::init(['method' => self::FALLBACK_METHOD], $sender, $reply_to, $return_path);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class WordPressMailer extends \PHPMailer {
|
||||
/** @var SubscribersRepository */
|
||||
private $subscribers_repository;
|
||||
|
||||
function __construct(
|
||||
public function __construct(
|
||||
Mailer $mailer,
|
||||
Mailer $fallback_mailer,
|
||||
MetaInfo $mailerMetaInfo,
|
||||
@ -38,7 +38,7 @@ class WordPressMailer extends \PHPMailer {
|
||||
$this->subscribers_repository = $subscribers_repository;
|
||||
}
|
||||
|
||||
function send() {
|
||||
public function send() {
|
||||
// We need this so that the \PHPMailer class will correctly prepare all the headers.
|
||||
$this->Mailer = 'mail';
|
||||
|
||||
|
@ -21,7 +21,7 @@ class WordpressMailerReplacer {
|
||||
/** @var SubscribersRepository */
|
||||
private $subscribers_repository;
|
||||
|
||||
function __construct(
|
||||
public function __construct(
|
||||
Mailer $mailer,
|
||||
MetaInfo $mailerMetaInfo,
|
||||
SettingsController $settings,
|
||||
|
Reference in New Issue
Block a user