mailpoet
/
vendor
/
woocommerce
/
email-editor
/
src
/
Engine
/
Renderer
/
ContentRenderer
/
class-process-manager.php
mailpoet
/
vendor
/
woocommerce
/
email-editor
/
src
/
Engine
/
Renderer
/
ContentRenderer
Last commit date
Layout
4 days ago
Postprocessors
11 months ago
Preprocessors
2 weeks ago
class-block-renderer.php
11 months ago
class-blocks-parser.php
11 months ago
class-content-renderer.php
4 days ago
class-preset-variable-resolver.php
3 months ago
class-process-manager.php
3 months ago
class-rendering-context.php
3 months ago
content.css
11 months ago
index.php
11 months ago
class-process-manager.php
62 lines
| 1 | <?php |
| 2 | declare(strict_types = 1); |
| 3 | namespace Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Postprocessors\Highlighting_Postprocessor; |
| 6 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Postprocessors\Postprocessor; |
| 7 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Postprocessors\Variables_Postprocessor; |
| 8 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Blocks_Width_Preprocessor; |
| 9 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Cleanup_Preprocessor; |
| 10 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Context_Aware_Preprocessor; |
| 11 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Preprocessor; |
| 12 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Spacing_Preprocessor; |
| 13 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Typography_Preprocessor; |
| 14 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Quote_Preprocessor; |
| 15 | use Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Postprocessors\Border_Style_Postprocessor; |
| 16 | class Process_Manager { |
| 17 | private $preprocessors = array(); |
| 18 | private $postprocessors = array(); |
| 19 | public function __construct( |
| 20 | Cleanup_Preprocessor $cleanup_preprocessor, |
| 21 | Blocks_Width_Preprocessor $blocks_width_preprocessor, |
| 22 | Typography_Preprocessor $typography_preprocessor, |
| 23 | Spacing_Preprocessor $spacing_preprocessor, |
| 24 | Quote_Preprocessor $quote_preprocessor, |
| 25 | Highlighting_Postprocessor $highlighting_postprocessor, |
| 26 | Variables_Postprocessor $variables_postprocessor, |
| 27 | Border_Style_Postprocessor $border_style_postprocessor |
| 28 | ) { |
| 29 | $this->register_preprocessor( $cleanup_preprocessor ); |
| 30 | // Spacing must run before Width: it sets root-padding-left/right in |
| 31 | // email_attrs, which the Width preprocessor reads to subtract root |
| 32 | // padding only from blocks that actually receive it. |
| 33 | $this->register_preprocessor( $spacing_preprocessor ); |
| 34 | $this->register_preprocessor( $blocks_width_preprocessor ); |
| 35 | $this->register_preprocessor( $typography_preprocessor ); |
| 36 | $this->register_preprocessor( $quote_preprocessor ); |
| 37 | $this->register_postprocessor( $highlighting_postprocessor ); |
| 38 | $this->register_postprocessor( $border_style_postprocessor ); |
| 39 | $this->register_postprocessor( $variables_postprocessor ); |
| 40 | } |
| 41 | public function preprocess( array $parsed_blocks, array $layout, array $styles, ?Rendering_Context $rendering_context = null ): array { |
| 42 | foreach ( $this->preprocessors as $preprocessor ) { |
| 43 | $parsed_blocks = $preprocessor instanceof Context_Aware_Preprocessor |
| 44 | ? $preprocessor->preprocess_with_context( $parsed_blocks, $layout, $styles, $rendering_context ) |
| 45 | : $preprocessor->preprocess( $parsed_blocks, $layout, $styles ); |
| 46 | } |
| 47 | return $parsed_blocks; |
| 48 | } |
| 49 | public function postprocess( string $html ): string { |
| 50 | foreach ( $this->postprocessors as $postprocessor ) { |
| 51 | $html = $postprocessor->postprocess( $html ); |
| 52 | } |
| 53 | return $html; |
| 54 | } |
| 55 | public function register_preprocessor( Preprocessor $preprocessor ): void { |
| 56 | $this->preprocessors[] = $preprocessor; |
| 57 | } |
| 58 | public function register_postprocessor( Postprocessor $postprocessor ): void { |
| 59 | $this->postprocessors[] = $postprocessor; |
| 60 | } |
| 61 | } |
| 62 |