-
Notifications
You must be signed in to change notification settings - Fork 57
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
Added Structured Table Type #353
base: 1.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\DataImporterBundle\Mapping\Operator\Factory; | ||
|
||
use Pimcore\Bundle\DataImporterBundle\Mapping\Operator\AbstractOperator; | ||
use Pimcore\Bundle\DataImporterBundle\Mapping\Type\TransformationDataTypeService; | ||
use Pimcore\Model\DataObject\Data\StructuredTable; | ||
|
||
class AsStructuredTable extends AbstractOperator | ||
{ | ||
/** | ||
* @param mixed $inputData | ||
* @param bool $dryRun | ||
* | ||
* @return StructuredTable|string | ||
*/ | ||
public function process($inputData, bool $dryRun = false) | ||
{ | ||
if (!is_array($inputData)) { | ||
$inputData = [$inputData]; | ||
} | ||
if ($dryRun) { | ||
if (empty($inputData)) { | ||
return ""; | ||
} | ||
return (new StructuredTable($inputData))->getHtmlTable( | ||
array_map(function ($value, $label) { | ||
return [ | ||
'key' => $value, | ||
'label' => $label, | ||
]; | ||
}, array_keys($inputData), array_keys(array_values($inputData)[0])), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
array_map(function ($value) { | ||
return [ | ||
'label' => $value, | ||
]; | ||
}, array_keys($inputData)), | ||
); | ||
} | ||
return new StructuredTable($inputData); | ||
} | ||
|
||
/** | ||
* @param string $inputType | ||
* @param int|null $index | ||
* | ||
* @return string | ||
*/ | ||
public function evaluateReturnType(string $inputType, int $index = null): string | ||
{ | ||
return TransformationDataTypeService::DEFAULT_ARRAY; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we would need to introduce there an extra type which just allows assignment to structured table fields, like we have it for quantity value, gallery etc. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,9 @@ class TransformationDataTypeService | |
self::DEFAULT_ARRAY => [ | ||
'multiselect', | ||
'countrymultiselect', | ||
'languages' | ||
'languages', | ||
'table', | ||
'structuredTable' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be moved to an extra type... |
||
], | ||
self::QUANTITY_VALUE => [ | ||
'quantityValue' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
pimcore.registerNS('pimcore.plugin.pimcoreDataImporterBundle.configuration.components.mapping.operator.asStructuredTable'); | ||
pimcore.plugin.pimcoreDataImporterBundle.configuration.components.mapping.operator.asStructuredTable = Class.create(pimcore.plugin.pimcoreDataImporterBundle.configuration.components.mapping.abstractOperator, { | ||
|
||
type: 'asStructuredTable', | ||
|
||
getMenuGroup: function () { | ||
return this.menuGroups.dataTypes; | ||
}, | ||
|
||
getIconClass: function () { | ||
return "pimcore_icon_structuredTable"; | ||
}, | ||
}); |
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.
Why return a html table here?
Shouldn't be that in
generateResultPreview
, as for example here