Add Send_Preview_Email class for MailPoet email editor
MAILPOET-6092
This commit is contained in:
committed by
Rostislav Wolný
parent
87676ccdb6
commit
ee967015dc
@ -8,6 +8,7 @@
|
||||
declare(strict_types = 1);
|
||||
namespace MailPoet\EmailEditor\Engine;
|
||||
|
||||
use MailPoet\EmailEditor\Integrations\Utils\Send_Preview_Email;
|
||||
use MailPoet\EmailEditor\Validator\Builder;
|
||||
use WP_Post;
|
||||
use WP_REST_Request;
|
||||
@ -17,6 +18,23 @@ use WP_REST_Response;
|
||||
* Class for email API controller.
|
||||
*/
|
||||
class Email_Api_Controller {
|
||||
|
||||
/**
|
||||
* Property for the send preview email controller.
|
||||
*
|
||||
* @var Send_Preview_Email Send Preview controller.
|
||||
*/
|
||||
private Send_Preview_Email $send_Preview_Email;
|
||||
|
||||
/**
|
||||
* Email_Api_Controller constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
Send_Preview_Email $send_Preview_Email
|
||||
) {
|
||||
$this->send_Preview_Email = $send_Preview_Email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns email specific data.
|
||||
*
|
||||
@ -39,7 +57,12 @@ class Email_Api_Controller {
|
||||
|
||||
public function send_preview_email_data( WP_REST_Request $request ): WP_REST_Response {
|
||||
$data = $request->get_params();
|
||||
return new WP_REST_Response(['success' => true, 'data' => $data], 200);
|
||||
try {
|
||||
$result = $this->send_Preview_Email->sendPreviewEmail($data);
|
||||
return new WP_REST_Response(['success' => true, 'result' => $result], 200);
|
||||
} catch ( \Exception $exception ) {
|
||||
return new WP_REST_Response(['error' => $exception->getMessage()], 400);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user