-
Notifications
You must be signed in to change notification settings - Fork 0
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
V1: prototype product API 2 CSV with json buffer #38
base: obelink-xml-v3
Are you sure you want to change the base?
Conversation
'currencies' => [], | ||
'has_locale' => false, | ||
'has_scope' => false, | ||
], $context); | ||
} | ||
|
||
public function add($code, string $type, array $context = []): void | ||
public function addValue($code, string $type, array $context = []): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force code for string input.
{ | ||
if ($this->pipeline === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use is_null function instead?
@@ -292,6 +305,11 @@ public function createWriter(array $configuration): ItemWriterInterface | |||
$factory = $this->factory->getFactory('writer'); | |||
$writer = $factory->createFromConfiguration($configuration, $this->getWorkFileManager()); | |||
|
|||
if (isset($configuration['converter'])) { | |||
$converter = $this->createConverter($configuration['converter']); | |||
$this->config->getPipeline()->line(new RevertPipe($converter)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$converter variable needed? $this->config->getPipeline()->line(new RevertPipe($this->createConverter($configuration['converter'])));
@@ -348,6 +366,11 @@ public function createReader(array $configuration) | |||
$factory = $this->factory->getFactory('reader'); | |||
$reader = $factory->createFromConfiguration($cursor, $configuration, $this->getConfig()); | |||
|
|||
if (isset($configuration['converter'])) { | |||
$converter = $this->createConverter($configuration['converter']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. Variable needed?
]; | ||
private $decoder; | ||
|
||
public function convert(array $item): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code duplication AkeneoProductApiConverter? Can we use one function for this?
case $class instanceof StringFormat: | ||
$item[$property] = $class->reverseFormat($item[$property]); | ||
break; | ||
case $class instanceof ArrayFormat: | ||
$item = $class->reverseFormat($item); | ||
$item = $class->reverseFormat($item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo
if (isset($item[$property])) { | ||
foreach ($matches as $match) { | ||
$this->processMatch($item, $property, $match); | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid else, use continue instead
$this->getOption('separator') | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove whitespace
{ | ||
return $this->implodeKeys($value, $this->getOption('separator')); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove whitespace
$newPath = $path . $key; | ||
if (is_array($value) && $value !== []) { | ||
$this->implodeKeys($value, $separator, $result, $newPath . $separator); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use continue instead
{ | ||
foreach ($array as $key => $value) { | ||
$newPath = $path . $key; | ||
if (is_array($value) && $value !== []) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!empty?
$newPath = $path . $key; | ||
if (is_array($value) && $value !== []) { | ||
$this->implodeKeys($value, $separator, $result, $newPath . $separator); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use continue
}); | ||
} elseif (is_string($rowValue) && in_array($rowValue, ['UNIQUE', 'IS_NOT_NUMERIC', 'NOT_EMPTY', 'NOT_NULL'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use switch with default here?
54f0136
to
3b7e6f2
Compare
This PR is meant to improve the handling API payload data in a better way.
It already introduced the following improvements:
We are focusing on the following possible workflows ::
-> Fetch some API data, do some actions, respond with API data
-> Fetch some API data, do some actions, respond with API data, over a downloadable CSV
-> Fetch a CSV file, do some actions, respond with API data
All Actions have now Flat version tests so we can't break any of the current logic when we go and implement the new logic.
TODO