From 26896d3cb7e0cd697d8b3f65f46b15c31c2521e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Thu, 18 Apr 2024 13:13:35 +0200 Subject: [PATCH] Move email default content to NewsletterSaveController To avoid circular reference I moved default content to NewsletterSaveController. [MAILPOET-5971] --- .../Integrations/MailPoet/EmailEditor.php | 23 ------------- .../Newsletter/NewsletterSaveController.php | 32 ++++++++++++++++--- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/mailpoet/lib/EmailEditor/Integrations/MailPoet/EmailEditor.php b/mailpoet/lib/EmailEditor/Integrations/MailPoet/EmailEditor.php index 014f2330ac..dc14559e06 100644 --- a/mailpoet/lib/EmailEditor/Integrations/MailPoet/EmailEditor.php +++ b/mailpoet/lib/EmailEditor/Integrations/MailPoet/EmailEditor.php @@ -62,27 +62,4 @@ class EmailEditor { 'schema' => $this->emailApiController->getEmailDataSchema(), ]); } - - public function getEmailDefaultContent(): string { - return ' - -
Your Logo
- - -

- - -
- - -

- - -

' . esc_html__('You received this email because you are subscribed to the [site:title]', 'mailpoet') . '

- - -

' . esc_html__('Unsubscribe', 'mailpoet') . ' | ' . esc_html__('Manage subscription', 'mailpoet') . '

- - '; - } } diff --git a/mailpoet/lib/Newsletter/NewsletterSaveController.php b/mailpoet/lib/Newsletter/NewsletterSaveController.php index dfa663d0b7..8a8587f792 100644 --- a/mailpoet/lib/Newsletter/NewsletterSaveController.php +++ b/mailpoet/lib/Newsletter/NewsletterSaveController.php @@ -78,8 +78,7 @@ class NewsletterSaveController { /*** @var NewsletterCoupon */ private $newsletterCoupon; - /** @var EmailEditor */ - private $emailEditor; + private CdnAssetUrl $cdnAssetUrl; public function __construct( AuthorizedEmailsController $authorizedEmailsController, @@ -98,7 +97,7 @@ class NewsletterSaveController { ApiDataSanitizer $dataSanitizer, Scheduler $scheduler, NewsletterCoupon $newsletterCoupon, - EmailEditor $emailEditor + CdnAssetUrl $cdnAssetUrl ) { $this->authorizedEmailsController = $authorizedEmailsController; $this->emoji = $emoji; @@ -116,7 +115,7 @@ class NewsletterSaveController { $this->dataSanitizer = $dataSanitizer; $this->scheduler = $scheduler; $this->newsletterCoupon = $newsletterCoupon; - $this->emailEditor = $emailEditor; + $this->cdnAssetUrl = $cdnAssetUrl; } public function save(array $data = []): NewsletterEntity { @@ -463,7 +462,7 @@ class NewsletterSaveController { } $newPostId = $this->wp->wpInsertPost([ - 'post_content' => $this->emailEditor->getEmailDefaultContent(), + 'post_content' => $this->getEmailDefaultContent(), 'post_type' => EmailEditor::MAILPOET_EMAIL_POST_TYPE, 'post_status' => 'draft', 'post_author' => $this->wp->getCurrentUserId(), @@ -472,4 +471,27 @@ class NewsletterSaveController { $newsletter->setWpPost($this->entityManager->getReference(WpPostEntity::class, $newPostId)); $this->entityManager->flush(); } + + private function getEmailDefaultContent(): string { + return ' + +
Your Logo
+ + +

+ + +
+ + +

+ + +

' . esc_html__('You received this email because you are subscribed to the [site:title]', 'mailpoet') . '

+ + +

' . esc_html__('Unsubscribe', 'mailpoet') . ' | ' . esc_html__('Manage subscription', 'mailpoet') . '

+ + '; + } }