Use MailerFactory in Mailer api
[MAILPOET-4115]
This commit is contained in:
committed by
Veljko V
parent
06fb13bd86
commit
6b758d90e6
@ -5,6 +5,7 @@ namespace MailPoet\API\JSON\v1;
|
||||
use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
||||
use MailPoet\API\JSON\Error as APIError;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\Mailer\MailerFactory;
|
||||
use MailPoet\Mailer\MailerLog;
|
||||
use MailPoet\Mailer\MetaInfo;
|
||||
use MailPoet\Services\AuthorizedEmailsController;
|
||||
@ -26,6 +27,9 @@ class Mailer extends APIEndpoint {
|
||||
/** @var MetaInfo */
|
||||
private $mailerMetaInfo;
|
||||
|
||||
/** @var MailerFactory */
|
||||
private $mailerFactory;
|
||||
|
||||
public $permissions = [
|
||||
'global' => AccessControl::PERMISSION_MANAGE_EMAILS,
|
||||
];
|
||||
@ -34,21 +38,22 @@ class Mailer extends APIEndpoint {
|
||||
AuthorizedEmailsController $authorizedEmailsController,
|
||||
SettingsController $settings,
|
||||
Bridge $bridge,
|
||||
MailerFactory $mailerFactory,
|
||||
MetaInfo $mailerMetaInfo
|
||||
) {
|
||||
$this->authorizedEmailsController = $authorizedEmailsController;
|
||||
$this->settings = $settings;
|
||||
$this->bridge = $bridge;
|
||||
$this->mailerFactory = $mailerFactory;
|
||||
$this->mailerMetaInfo = $mailerMetaInfo;
|
||||
}
|
||||
|
||||
public function send($data = []) {
|
||||
try {
|
||||
$mailer = new \MailPoet\Mailer\Mailer();
|
||||
$mailer->init(
|
||||
(isset($data['mailer'])) ? $data['mailer'] : false,
|
||||
(isset($data['sender'])) ? $data['sender'] : false,
|
||||
(isset($data['reply_to'])) ? $data['reply_to'] : false
|
||||
$mailer = $this->mailerFactory->buildMailer(
|
||||
(isset($data['mailer'])) ? $data['mailer'] : null,
|
||||
(isset($data['sender'])) ? $data['sender'] : null,
|
||||
(isset($data['reply_to'])) ? $data['reply_to'] : null
|
||||
);
|
||||
// report this as 'sending_test' in metadata since this endpoint is only used to test sending methods for now
|
||||
$extraParams = [
|
||||
|
Reference in New Issue
Block a user