diff --git a/lib/DI/ContainerConfigurator.php b/lib/DI/ContainerConfigurator.php
index caf01a0e04..d4bd0cd461 100644
--- a/lib/DI/ContainerConfigurator.php
+++ b/lib/DI/ContainerConfigurator.php
@@ -374,6 +374,7 @@ class ContainerConfigurator implements IContainerConfigurator {
$container->autowire(\MailPoet\WooCommerce\TransactionalEmails::class)->setPublic(true);
$container->autowire(\MailPoet\WooCommerce\TransactionalEmails\Template::class)->setPublic(true);
$container->autowire(\MailPoet\WooCommerce\TransactionalEmails\Renderer::class)->setPublic(true);
+ $container->autowire(\MailPoet\WooCommerce\TransactionalEmails\ContentPreprocessor::class)->setPublic(true);
// WordPress
$container->autowire(\MailPoet\WP\Emoji::class)->setPublic(true);
$container->autowire(\MailPoet\WP\Functions::class)->setPublic(true);
diff --git a/lib/Newsletter/Renderer/Preprocessor.php b/lib/Newsletter/Renderer/Preprocessor.php
index 5e1a0145a6..16e1ea5e4d 100644
--- a/lib/Newsletter/Renderer/Preprocessor.php
+++ b/lib/Newsletter/Renderer/Preprocessor.php
@@ -3,16 +3,12 @@
namespace MailPoet\Newsletter\Renderer;
use MailPoet\Entities\NewsletterEntity;
-use MailPoet\Newsletter\Editor\LayoutHelper;
use MailPoet\Newsletter\Renderer\Blocks\AbandonedCartContent;
use MailPoet\Newsletter\Renderer\Blocks\AutomatedLatestContentBlock;
use MailPoet\Tasks\Sending as SendingTask;
-use MailPoet\WooCommerce\TransactionalEmails;
+use MailPoet\WooCommerce\TransactionalEmails\ContentPreprocessor;
class Preprocessor {
- const WC_HEADING_PLACEHOLDER = '[mailpoet_woocommerce_heading_placeholder]';
- const WC_CONTENT_PLACEHOLDER = '[mailpoet_woocommerce_content_placeholder]';
-
const WC_HEADING_BEFORE = '
@@ -28,17 +24,17 @@ class Preprocessor {
/** @var AutomatedLatestContentBlock */
private $automatedLatestContent;
- /** @var TransactionalEmails */
- private $transactionalEmails;
+ /** @var ContentPreprocessor */
+ private $wooCommerceContentPreprocessor;
public function __construct(
AbandonedCartContent $abandonedCartContent,
AutomatedLatestContentBlock $automatedLatestContent,
- TransactionalEmails $transactionalEmails
+ ContentPreprocessor $wooCommerceContentPreprocessor
) {
$this->abandonedCartContent = $abandonedCartContent;
$this->automatedLatestContent = $automatedLatestContent;
- $this->transactionalEmails = $transactionalEmails;
+ $this->wooCommerceContentPreprocessor = $wooCommerceContentPreprocessor;
}
/**
@@ -68,34 +64,10 @@ class Preprocessor {
case 'automatedLatestContentLayout':
return $this->automatedLatestContent->render($newsletter, $block);
case 'woocommerceHeading':
- $wcEmailSettings = $this->transactionalEmails->getWCEmailSettings();
- $content = self::WC_HEADING_BEFORE . '' . self::WC_HEADING_PLACEHOLDER . '
' . self::WC_HEADING_AFTER;
- return $this->renderTextBlock($content, ['backgroundColor' => $wcEmailSettings['base_color']]);
+ return $this->wooCommerceContentPreprocessor->preprocessHeader();
case 'woocommerceContent':
- return $this->renderPlaceholderBlock(self::WC_CONTENT_PLACEHOLDER);
+ return $this->wooCommerceContentPreprocessor->preprocessContent();
}
return [$block];
}
-
- private function renderTextBlock(string $text, array $styles = []): array {
- return [
- LayoutHelper::row([
- LayoutHelper::col([[
- 'type' => 'text',
- 'text' => $text,
- ]]),
- ], $styles),
- ];
- }
-
- private function renderPlaceholderBlock(string $placeholder): array {
- return [
- LayoutHelper::row([
- LayoutHelper::col([[
- 'type' => 'placeholder',
- 'placeholder' => $placeholder,
- ]]),
- ]),
- ];
- }
}
diff --git a/lib/WooCommerce/TransactionalEmails/ContentPreprocessor.php b/lib/WooCommerce/TransactionalEmails/ContentPreprocessor.php
new file mode 100644
index 0000000000..70091fb30a
--- /dev/null
+++ b/lib/WooCommerce/TransactionalEmails/ContentPreprocessor.php
@@ -0,0 +1,61 @@
+
+
+ ';
+ public const WC_HEADING_AFTER = '
+ |
+
+
';
+
+ /** @var TransactionalEmails */
+ private $transactionalEmails;
+
+ public function __construct(
+ TransactionalEmails $transactionalEmails
+ ) {
+ $this->transactionalEmails = $transactionalEmails;
+ }
+
+ public function preprocessContent() {
+ return $this->renderPlaceholderBlock(self::WC_CONTENT_PLACEHOLDER);
+ }
+
+ public function preprocessHeader() {
+ $wcEmailSettings = $this->transactionalEmails->getWCEmailSettings();
+ $content = self::WC_HEADING_BEFORE . '' . self::WC_HEADING_PLACEHOLDER . '
' . self::WC_HEADING_AFTER;
+ return $this->renderTextBlock($content, ['backgroundColor' => $wcEmailSettings['base_color']]);
+ }
+
+ private function renderTextBlock(string $text, array $styles = []): array {
+ return [
+ LayoutHelper::row([
+ LayoutHelper::col([[
+ 'type' => 'text',
+ 'text' => $text,
+ ]]),
+ ], $styles),
+ ];
+ }
+
+ private function renderPlaceholderBlock(string $placeholder): array {
+ return [
+ LayoutHelper::row([
+ LayoutHelper::col([[
+ 'type' => 'placeholder',
+ 'placeholder' => $placeholder,
+ ]]),
+ ]),
+ ];
+ }
+}
diff --git a/lib/WooCommerce/TransactionalEmails/Renderer.php b/lib/WooCommerce/TransactionalEmails/Renderer.php
index 285a1bc344..00ed66add9 100644
--- a/lib/WooCommerce/TransactionalEmails/Renderer.php
+++ b/lib/WooCommerce/TransactionalEmails/Renderer.php
@@ -3,7 +3,6 @@
namespace MailPoet\WooCommerce\TransactionalEmails;
use MailPoet\Models\Newsletter;
-use MailPoet\Newsletter\Renderer\Preprocessor;
use MailPoet\Newsletter\Renderer\Renderer as NewsletterRenderer;
use MailPoetVendor\csstidy;
use MailPoetVendor\csstidy_print;
@@ -34,7 +33,7 @@ class Renderer {
}
public function render(Newsletter $newsletter, ?string $subject = null) {
- $html = explode(Preprocessor::WC_CONTENT_PLACEHOLDER, $this->renderer->renderAsPreview($newsletter, 'html', $subject));
+ $html = explode(ContentPreprocessor::WC_CONTENT_PLACEHOLDER, $this->renderer->renderAsPreview($newsletter, 'html', $subject));
$this->htmlBeforeContent = $html[0];
$this->htmlAfterContent = $html[1];
}
@@ -43,7 +42,7 @@ class Renderer {
if (empty($this->htmlBeforeContent)) {
throw new \Exception("You should call 'render' before 'getHTMLBeforeContent'");
}
- $html = str_replace(Preprocessor::WC_HEADING_PLACEHOLDER, $headingText, $this->htmlBeforeContent);
+ $html = str_replace(ContentPreprocessor::WC_HEADING_PLACEHOLDER, $headingText, $this->htmlBeforeContent);
return $html . '