Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error Type for JsonSerializationVisitor and XmlSerializationVisitor #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
31 changes: 27 additions & 4 deletions src/Command/ImportCreateConfigurationFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,14 +98,34 @@ 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
Expand Down