Use DI in block renderer

[MAILPOET-2899]
This commit is contained in:
Pavel Dohnal
2020-05-25 13:51:37 +02:00
committed by Veljko V
parent 7561730407
commit 5f73f9ee3e
5 changed files with 32 additions and 31 deletions

View File

@@ -32,15 +32,16 @@ class Preprocessor {
/**
* @param array $content
* @param array $newsletter
* @return array
*/
public function process($content) {
public function process($newsletter, $content) {
if (!array_key_exists('blocks', $content)) {
return $content;
}
$blocks = [];
foreach ($content['blocks'] as $block) {
$blocks = array_merge($blocks, $this->processBlock($block));
$blocks = array_merge($blocks, $this->processBlock($newsletter, $block));
}
$content['blocks'] = $blocks;
return $content;
@@ -48,12 +49,13 @@ class Preprocessor {
/**
* @param array $block
* @param array $newsletter
* @return array
*/
public function processBlock($block) {
public function processBlock($newsletter, $block) {
switch ($block['type']) {
case 'automatedLatestContentLayout':
return $this->blocksRenderer->automatedLatestContentTransformedPosts($block);
return $this->blocksRenderer->automatedLatestContentTransformedPosts($newsletter, $block);
case 'woocommerceHeading':
$wcEmailSettings = $this->transactionalEmails->getWCEmailSettings();
$content = self::WC_HEADING_BEFORE . '<h1 style="color:' . $wcEmailSettings['base_text_color'] . ';">' . self::WC_HEADING_PLACEHOLDER . '</h1>' . self::WC_HEADING_AFTER;