From 1db2d92cfe16778fba6dc3dadd55c63a7a12899d Mon Sep 17 00:00:00 2001 From: aymericcucherousset Date: Sun, 11 Jan 2026 13:05:47 +0100 Subject: [PATCH] Remove MJML v3 support BREAKING CHANGE: Drop support for MJML version 3 - Remove `mjml_version` configuration option - Remove `getMjmlVersion()` method from BinaryRenderer - Simplify BinaryRenderer to use MJML v4 CLI arguments only - Update README to reference MJML 4 only - Remove related tests --- README.md | 2 +- src/DependencyInjection/Configuration.php | 5 --- src/Renderer/BinaryRenderer.php | 46 ++--------------------- tests/Configuration/ConfigurationTest.php | 33 ---------------- tests/Renderer/BinaryRendererTest.php | 18 --------- 5 files changed, 4 insertions(+), 100 deletions(-) diff --git a/README.md b/README.md index 6d075c2..bbb6551 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Latest Stable Version](https://poser.pugx.org/notfloran/mjml-bundle/v/stable.svg)](https://packagist.org/packages/notfloran/mjml-bundle) [![Latest Unstable Version](https://poser.pugx.org/notfloran/mjml-bundle/v/unstable.svg)](https://packagist.org/packages/notfloran/mjml-bundle) -Bundle to use [MJML](https://mjml.io/) 3 and 4 with Symfony >= 3. +Bundle to use [MJML](https://mjml.io/) 4 with Symfony >= 3. ## Installation diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 97dbf68..bcf411e 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -49,11 +49,6 @@ public function getConfigTreeBuilder(): TreeBuilder ->booleanNode('minify') ->defaultFalse() ->end() - ->integerNode('mjml_version') - ->min(3)->max(4) - ->defaultNull() - ->info('Mjml version') - ->end() ->end() ->end() ->end() diff --git a/src/Renderer/BinaryRenderer.php b/src/Renderer/BinaryRenderer.php index 3225a60..478e062 100644 --- a/src/Renderer/BinaryRenderer.php +++ b/src/Renderer/BinaryRenderer.php @@ -6,9 +6,6 @@ final class BinaryRenderer implements RendererInterface { - private const VERSION_4 = 4; - private const VERSION_BEFORE_4 = 3; - /** * @var string */ @@ -24,51 +21,21 @@ final class BinaryRenderer implements RendererInterface */ private $validationLevel; - /** - * @var int|null - */ - private $mjmlVersion; - /** * @var string|null */ private $node; - public function __construct(string $bin, bool $minify, string $validationLevel, ?string $node = null, ?int $mjmlVersion = null) + public function __construct(string $bin, bool $minify, string $validationLevel, ?string $node = null) { $this->bin = $bin; $this->minify = $minify; $this->validationLevel = $validationLevel; $this->node = $node; - $this->mjmlVersion = $mjmlVersion; - } - - public function getMjmlVersion(): int - { - if (null === $this->mjmlVersion) { - $command = []; - if ($this->node) { - $command[] = $this->node; - } - - array_push($command, $this->bin, '--version'); - - $process = new Process($command); - $process->mustRun(); - - $this->mjmlVersion = self::VERSION_4; - if (false === strpos($process->getOutput(), 'mjml-core: 4.')) { - $this->mjmlVersion = self::VERSION_BEFORE_4; - } - } - - return $this->mjmlVersion; } public function render(string $mjmlContent): string { - $version = $this->getMjmlVersion(); - $command = []; if ($this->node) { $command[] = $this->node; @@ -76,19 +43,12 @@ public function render(string $mjmlContent): string array_push($command, $this->bin, '-i', '-s'); - $strictArgument = '-l'; - if (self::VERSION_4 === $version) { - $strictArgument = '--config.validationLevel'; - } + $strictArgument = '--config.validationLevel'; array_push($command, $strictArgument, $this->validationLevel); if (true === $this->minify) { - if (self::VERSION_4 === $version) { - array_push($command, '--config.minify', 'true'); - } else { - $command[] = '-m'; - } + array_push($command, '--config.minify', 'true'); } // Create process diff --git a/tests/Configuration/ConfigurationTest.php b/tests/Configuration/ConfigurationTest.php index 3af6807..a6a0812 100644 --- a/tests/Configuration/ConfigurationTest.php +++ b/tests/Configuration/ConfigurationTest.php @@ -99,37 +99,4 @@ public function testInvalidValidationLevelConfiguration() $this->assertConfigurationIsInvalid($config, 'Validation level is invalid'); } - - public function testMjmlVersionConfiguration() - { - $config = [ - [ - 'renderer' => 'binary', - 'options' => [ - 'binary' => 'mjml', - 'mjml_version' => 4, - ], - ], - ]; - - $this->assertConfigurationIsValid($config); - } - - public function testInvalidMjmlVersionConfiguration() - { - $config = [ - [ - 'renderer' => 'binary', - 'options' => [ - 'binary' => 'mjml', - 'mjml_version' => 2, - ], - ], - ]; - - $this->assertConfigurationIsInvalid( - $config, - 'The value 2 is too small for path "mjml.options.mjml_version". Should be greater than or equal to 3' - ); - } } diff --git a/tests/Renderer/BinaryRendererTest.php b/tests/Renderer/BinaryRendererTest.php index f07244a..e1ab490 100644 --- a/tests/Renderer/BinaryRendererTest.php +++ b/tests/Renderer/BinaryRendererTest.php @@ -56,24 +56,6 @@ public function testUseNode() $this->assertStringContains('html', $html); } - /** - * @dataProvider mjmlVersionDataProvider - */ - public function testUseMjmlVersion(int $mjmlVersion) - { - $renderer = new BinaryRenderer($this->getMjmlBinary(), false, 'strict', null, $mjmlVersion); - $html = $renderer->render(file_get_contents(__DIR__.'/../fixtures/basic.mjml')); - - $this->assertStringContains('html', $html); - $this->assertStringContains('Hello Floran from MJML and Symfony', $html); - } - - public function mjmlVersionDataProvider() - { - yield ['old version' => 3]; - yield ['actual version' => 4]; - } - /** * Allow to use PHPUnit < and > 9. *