From ad830edba0e8563136c5c92437c0c44c49eb5f8e Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Mon, 19 Jun 2023 15:35:11 +0200 Subject: [PATCH 1/3] Fix error Type for JsonSerializationVisitor and XmlSerializationVisitor --- .../ImportCreateConfigurationFileCommand.php | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/Command/ImportCreateConfigurationFileCommand.php b/src/Command/ImportCreateConfigurationFileCommand.php index 44346c1..b20432b 100644 --- a/src/Command/ImportCreateConfigurationFileCommand.php +++ b/src/Command/ImportCreateConfigurationFileCommand.php @@ -14,6 +14,9 @@ namespace TechDivision\Import\Cli\Command; +use Jean85\PrettyVersions; +use JMS\Serializer\Visitor\Factory\JsonSerializationVisitorFactory; +use JMS\Serializer\Visitor\Factory\XmlSerializationVisitorFactory; use JMS\Serializer\SerializerBuilder; use JMS\Serializer\XmlSerializationVisitor; use JMS\Serializer\JsonSerializationVisitor; @@ -95,14 +98,35 @@ protected function executeSimpleCommand( switch ($format) { // initialize the JSON visitor case 'json': - // initialize the visitor because we want to set JSON options - $visitor = new JsonSerializationVisitor($namingStrategy); - $visitor->setOptions(JSON_PRETTY_PRINT); + // try to load the JMS serializer + $version = PrettyVersions::getVersion('jms/serializer'); + + // query whether or not we're < than 2.0.0 + if (version_compare($version->getPrettyVersion(), '2.0.0', '<')) { + + // initialize the visitor because we want to set JSON options + $visitor = new JsonSerializationVisitor($namingStrategy); + $visitor->setOptions(JSON_PRETTY_PRINT); + } else { + // initialize the json visitor factory because we want to set JSON options + $visitor = new JsonSerializationVisitorFactory(); + } + break; // initialize the XML visitor case 'xml': - $visitor = new XmlSerializationVisitor($namingStrategy); + // try to load the JMS serializer + $version = PrettyVersions::getVersion('jms/serializer'); + + // query whether or not we're < than 2.0.0 + if (version_compare($version->getPrettyVersion(), '2.0.0', '<')) { + // initialize the visitor because we want to set JSON options + $visitor = new XmlSerializationVisitor($namingStrategy); + } else { + // initialize the json visitor factory because we want to set JSON options + $visitor = new XmlSerializationVisitorFactory(); + } break; // throw an execption in all other cases From 35e5bdb62f299e080cd9f1ff3184771b261b41fd Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Mon, 19 Jun 2023 15:42:15 +0200 Subject: [PATCH 2/3] Fix static test issue --- src/Command/ImportCreateConfigurationFileCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Command/ImportCreateConfigurationFileCommand.php b/src/Command/ImportCreateConfigurationFileCommand.php index b20432b..798ce1b 100644 --- a/src/Command/ImportCreateConfigurationFileCommand.php +++ b/src/Command/ImportCreateConfigurationFileCommand.php @@ -103,7 +103,6 @@ protected function executeSimpleCommand( // query whether or not we're < than 2.0.0 if (version_compare($version->getPrettyVersion(), '2.0.0', '<')) { - // initialize the visitor because we want to set JSON options $visitor = new JsonSerializationVisitor($namingStrategy); $visitor->setOptions(JSON_PRETTY_PRINT); From 9363aa6eea1afac72c01b32dd2ad79952dad655c Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Mon, 19 Jun 2023 16:20:02 +0200 Subject: [PATCH 3/3] uodate changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4f2d76..b4da991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Version 12.2.3 + +## Bugfixes + +* Fix command `import:create:configuration-file` query for Magento versions determination + # Version 12.2.2 ## Bugfixes