Add Preprocessor for removing unwanted blocks

[MAILPOET-5591]
This commit is contained in:
Jan Lysý
2023-10-12 18:30:25 +02:00
committed by Jan Lysý
parent c1768fd0b2
commit fe5eabfe49
9 changed files with 103 additions and 10 deletions

View File

@ -2,6 +2,7 @@
namespace MailPoet\EmailEditor\Engine\Renderer;
use MailPoet\EmailEditor\Engine\Renderer\Preprocessors\CleanupPreprocessor;
use MailPoet\EmailEditor\Engine\Renderer\Preprocessors\Preprocessor;
use MailPoet\EmailEditor\Engine\Renderer\Preprocessors\TopLevelPreprocessor;
@ -10,18 +11,21 @@ class PreprocessManager {
private $preprocessors = [];
public function __construct(
CleanupPreprocessor $cleanupPreprocessor,
TopLevelPreprocessor $topLevelPreprocessor
) {
$this->registerPreprocessor($cleanupPreprocessor);
$this->registerPreprocessor($topLevelPreprocessor);
}
/**
* @param array $parsedBlocks
* @param array{width: int, background: string, padding: array{bottom: int, left: int, right: int, top: int}} $layoutStyles
* @return array
*/
public function preprocess(array $parsedBlocks): array {
public function preprocess(array $parsedBlocks, array $layoutStyles): array {
foreach ($this->preprocessors as $preprocessor) {
$parsedBlocks = $preprocessor->preprocess($parsedBlocks);
$parsedBlocks = $preprocessor->preprocess($parsedBlocks, $layoutStyles);
}
return $parsedBlocks;
}