Move email default content to NewsletterSaveController
To avoid circular reference I moved default content to NewsletterSaveController. [MAILPOET-5971]
This commit is contained in:
@@ -62,27 +62,4 @@ class EmailEditor {
|
|||||||
'schema' => $this->emailApiController->getEmailDataSchema(),
|
'schema' => $this->emailApiController->getEmailDataSchema(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmailDefaultContent(): string {
|
|
||||||
return '
|
|
||||||
<!-- wp:image {"width":"130px","sizeSlug":"large"} -->
|
|
||||||
<figure class="wp-block-image size-large is-resized"><img src="' . esc_url($this->cdnAssetUrl->generateCdnUrl("email-editor/your-logo-placeholder.png")) . '" alt="Your Logo" style="width:130px"/></figure>
|
|
||||||
<!-- /wp:image -->
|
|
||||||
<!-- wp:heading {"fontSize":"medium","style":{"spacing":{"padding":{"top":"var:preset|spacing|10","bottom":"var:preset|spacing|10"}}}} -->
|
|
||||||
<h2 class="wp-block-heading has-medium-font-size" style="padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)"></h2>
|
|
||||||
<!-- /wp:heading -->
|
|
||||||
<!-- wp:image -->
|
|
||||||
<figure class="wp-block-image"><img alt=""/></figure>
|
|
||||||
<!-- /wp:image -->
|
|
||||||
<!-- wp:paragraph {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20"}}}} -->
|
|
||||||
<p style="padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)"></p>
|
|
||||||
<!-- /wp:paragraph -->
|
|
||||||
<!-- wp:paragraph {"fontSize":"small"} -->
|
|
||||||
<p class="has-small-font-size">' . esc_html__('You received this email because you are subscribed to the [site:title]', 'mailpoet') . '</p>
|
|
||||||
<!-- /wp:paragraph -->
|
|
||||||
<!-- wp:paragraph {"fontSize":"small"} -->
|
|
||||||
<p class="has-small-font-size"><a href="[link:subscription_unsubscribe_url]">' . esc_html__('Unsubscribe', 'mailpoet') . '</a> | <a href="[link:subscription_manage_url]">' . esc_html__('Manage subscription', 'mailpoet') . '</a></p>
|
|
||||||
<!-- /wp:paragraph -->
|
|
||||||
';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -78,8 +78,7 @@ class NewsletterSaveController {
|
|||||||
/*** @var NewsletterCoupon */
|
/*** @var NewsletterCoupon */
|
||||||
private $newsletterCoupon;
|
private $newsletterCoupon;
|
||||||
|
|
||||||
/** @var EmailEditor */
|
private CdnAssetUrl $cdnAssetUrl;
|
||||||
private $emailEditor;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AuthorizedEmailsController $authorizedEmailsController,
|
AuthorizedEmailsController $authorizedEmailsController,
|
||||||
@@ -98,7 +97,7 @@ class NewsletterSaveController {
|
|||||||
ApiDataSanitizer $dataSanitizer,
|
ApiDataSanitizer $dataSanitizer,
|
||||||
Scheduler $scheduler,
|
Scheduler $scheduler,
|
||||||
NewsletterCoupon $newsletterCoupon,
|
NewsletterCoupon $newsletterCoupon,
|
||||||
EmailEditor $emailEditor
|
CdnAssetUrl $cdnAssetUrl
|
||||||
) {
|
) {
|
||||||
$this->authorizedEmailsController = $authorizedEmailsController;
|
$this->authorizedEmailsController = $authorizedEmailsController;
|
||||||
$this->emoji = $emoji;
|
$this->emoji = $emoji;
|
||||||
@@ -116,7 +115,7 @@ class NewsletterSaveController {
|
|||||||
$this->dataSanitizer = $dataSanitizer;
|
$this->dataSanitizer = $dataSanitizer;
|
||||||
$this->scheduler = $scheduler;
|
$this->scheduler = $scheduler;
|
||||||
$this->newsletterCoupon = $newsletterCoupon;
|
$this->newsletterCoupon = $newsletterCoupon;
|
||||||
$this->emailEditor = $emailEditor;
|
$this->cdnAssetUrl = $cdnAssetUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(array $data = []): NewsletterEntity {
|
public function save(array $data = []): NewsletterEntity {
|
||||||
@@ -463,7 +462,7 @@ class NewsletterSaveController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$newPostId = $this->wp->wpInsertPost([
|
$newPostId = $this->wp->wpInsertPost([
|
||||||
'post_content' => $this->emailEditor->getEmailDefaultContent(),
|
'post_content' => $this->getEmailDefaultContent(),
|
||||||
'post_type' => EmailEditor::MAILPOET_EMAIL_POST_TYPE,
|
'post_type' => EmailEditor::MAILPOET_EMAIL_POST_TYPE,
|
||||||
'post_status' => 'draft',
|
'post_status' => 'draft',
|
||||||
'post_author' => $this->wp->getCurrentUserId(),
|
'post_author' => $this->wp->getCurrentUserId(),
|
||||||
@@ -472,4 +471,27 @@ class NewsletterSaveController {
|
|||||||
$newsletter->setWpPost($this->entityManager->getReference(WpPostEntity::class, $newPostId));
|
$newsletter->setWpPost($this->entityManager->getReference(WpPostEntity::class, $newPostId));
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getEmailDefaultContent(): string {
|
||||||
|
return '
|
||||||
|
<!-- wp:image {"width":"130px","sizeSlug":"large"} -->
|
||||||
|
<figure class="wp-block-image size-large is-resized"><img src="' . esc_url($this->cdnAssetUrl->generateCdnUrl("email-editor/your-logo-placeholder.png")) . '" alt="Your Logo" style="width:130px"/></figure>
|
||||||
|
<!-- /wp:image -->
|
||||||
|
<!-- wp:heading {"fontSize":"medium","style":{"spacing":{"padding":{"top":"var:preset|spacing|10","bottom":"var:preset|spacing|10"}}}} -->
|
||||||
|
<h2 class="wp-block-heading has-medium-font-size" style="padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)"></h2>
|
||||||
|
<!-- /wp:heading -->
|
||||||
|
<!-- wp:image -->
|
||||||
|
<figure class="wp-block-image"><img alt=""/></figure>
|
||||||
|
<!-- /wp:image -->
|
||||||
|
<!-- wp:paragraph {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20"}}}} -->
|
||||||
|
<p style="padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)"></p>
|
||||||
|
<!-- /wp:paragraph -->
|
||||||
|
<!-- wp:paragraph {"fontSize":"small"} -->
|
||||||
|
<p class="has-small-font-size">' . esc_html__('You received this email because you are subscribed to the [site:title]', 'mailpoet') . '</p>
|
||||||
|
<!-- /wp:paragraph -->
|
||||||
|
<!-- wp:paragraph {"fontSize":"small"} -->
|
||||||
|
<p class="has-small-font-size"><a href="[link:subscription_unsubscribe_url]">' . esc_html__('Unsubscribe', 'mailpoet') . '</a> | <a href="[link:subscription_manage_url]">' . esc_html__('Manage subscription', 'mailpoet') . '</a></p>
|
||||||
|
<!-- /wp:paragraph -->
|
||||||
|
';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user