-
Notifications
You must be signed in to change notification settings - Fork 61
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
Data Selector for JSON Payload #437
base: 1.x
Are you sure you want to change the base?
Conversation
@@ -45,6 +45,7 @@ plugin_pimcore_datahub_data_importer_configpanel_csv_escape: Escape | |||
plugin_pimcore_datahub_data_importer_configpanel_xlsx_sheet: Sheet | |||
plugin_pimcore_datahub_data_importer_configpanel_xml_xpath: XPath | |||
plugin_pimcore_datahub_data_importer_configpanel_xml_schema: Schema | |||
plugin_pimcore_datahub_data_importer_configpanel_json_path: Path |
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.
I have seen the name "path" and "expression" used. do we have a preference?
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.
I would go for path?
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.
or name it what it is .. the jmesPath?
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.
How about "JMESPath"? That is what is shown here: https://jmespath.org/tutorial.html
xtype: 'textfield', | ||
fieldLabel: t('plugin_pimcore_datahub_data_importer_configpanel_json_path'), | ||
name: this.dataNamePrefix + 'path', | ||
value: this.data.path || '', |
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.
do I need anything else here, such as:
allowBlank: true,
msgTarget: 'under'
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.
don't think so, should be fine.
@@ -32,13 +35,17 @@ class JsonFileInterpreter extends AbstractInterpreter | |||
|
|||
protected function loadData(string $path): array | |||
{ | |||
if ($this->cachedFilePath === $path && !empty($this->cachedContent)) { | |||
if ($this->cachedFilePath !== $path || empty($this->cachedContent)) { |
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.
i believe this logic was wrong before. See fix for Xml: #438
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.
I'm wondering for what we need that caching at all?
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.
I just kept the logic as is (or how it was supposed to be). if the caching does not make sense, can that be removed in a subsequent PR?
|
@@ -52,7 +63,7 @@ protected function doInterpretFileAndCallProcessRow(string $path): void | |||
|
|||
public function setSettings(array $settings): void | |||
{ | |||
//nothing to do | |||
$this->path = $settings['path']; |
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.
do we want to do any validation here that the path passed in is a valid JmesPath?
@@ -32,13 +35,17 @@ class JsonFileInterpreter extends AbstractInterpreter | |||
|
|||
protected function loadData(string $path): array | |||
{ | |||
if ($this->cachedFilePath === $path && !empty($this->cachedContent)) { | |||
if ($this->cachedFilePath !== $path || empty($this->cachedContent)) { |
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.
I'm wondering for what we need that caching at all?
@@ -45,6 +45,7 @@ plugin_pimcore_datahub_data_importer_configpanel_csv_escape: Escape | |||
plugin_pimcore_datahub_data_importer_configpanel_xlsx_sheet: Sheet | |||
plugin_pimcore_datahub_data_importer_configpanel_xml_xpath: XPath | |||
plugin_pimcore_datahub_data_importer_configpanel_xml_schema: Schema | |||
plugin_pimcore_datahub_data_importer_configpanel_json_path: Path |
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.
I would go for path?
xtype: 'textfield', | ||
fieldLabel: t('plugin_pimcore_datahub_data_importer_configpanel_json_path'), | ||
name: this.dataNamePrefix + 'path', | ||
value: this.data.path || '', |
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.
don't think so, should be fine.
@@ -45,6 +45,7 @@ plugin_pimcore_datahub_data_importer_configpanel_csv_escape: Escape | |||
plugin_pimcore_datahub_data_importer_configpanel_xlsx_sheet: Sheet | |||
plugin_pimcore_datahub_data_importer_configpanel_xml_xpath: XPath | |||
plugin_pimcore_datahub_data_importer_configpanel_xml_schema: Schema | |||
plugin_pimcore_datahub_data_importer_configpanel_json_path: Path |
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.
or name it what it is .. the jmesPath?
See: https://github.com/orgs/pimcore/discussions/17670#discussion-7265373
CC @fashxp
This does add a new dep: "mtdowling/jmespath.php" (https://github.com/jmespath/jmespath.php)