From 74d46a844b7384dc21ea74f1849a8f67ca00cabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanel=20P=C3=A4=C3=A4ro?= Date: Wed, 7 Feb 2024 14:02:19 +0200 Subject: [PATCH] ability to enable/disable value inheritance when exporting --- .../Exporter/Exporter.php | 6 ++++++ .../Form/Type/ExportDefinitionType.php | 1 + .../Model/ExportDefinition.php | 21 +++++++++++++++++++ .../Model/ExportDefinition/Dao.php | 1 + .../Model/ExportDefinitionInterface.php | 10 +++++++++ .../serializer/Model.ExportDefinition.yml | 4 ++++ .../public/pimcore/js/export/item.js | 6 ++++++ .../Resources/translations/admin.en.yml | 1 + 8 files changed, 50 insertions(+) diff --git a/src/DataDefinitionsBundle/Exporter/Exporter.php b/src/DataDefinitionsBundle/Exporter/Exporter.php index 736fbc7a..c1f794db 100644 --- a/src/DataDefinitionsBundle/Exporter/Exporter.php +++ b/src/DataDefinitionsBundle/Exporter/Exporter.php @@ -21,6 +21,7 @@ use Exception; use InvalidArgumentException; use Pimcore; +use Pimcore\Model\DataObject; use Pimcore\Model\DataObject\Concrete; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -116,6 +117,9 @@ private function runExport( FetcherInterface $fetcher, ExportProviderInterface $provider ) { + $getInheritedValues = DataObject::getGetInheritedValues(); + DataObject::setGetInheritedValues($definition->isEnableInheritance()); + UnpublishedHelper::hideUnpublished( function () use ($definition, $params, $total, $fetcher, $provider, $fetcherContext) { $count = 0; @@ -180,6 +184,8 @@ function () use ($definition, $params, $total, $fetcher, $provider, $fetcherCont }, false === $definition->isFetchUnpublished() ); + + DataObject::setGetInheritedValues($getInheritedValues); } private function exportRow( diff --git a/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php b/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php index 7ffa436f..95764898 100644 --- a/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php +++ b/src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php @@ -52,6 +52,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add('runner', ExportRunnerChoiceType::class) ->add('name', TextType::class) ->add('stopOnException', CheckboxType::class) + ->add('enableInheritance', CheckboxType::class) ->add('fetchUnpublished', CheckboxType::class) ->add('failureNotificationDocument', IntegerType::class) ->add('successNotificationDocument', IntegerType::class) diff --git a/src/DataDefinitionsBundle/Model/ExportDefinition.php b/src/DataDefinitionsBundle/Model/ExportDefinition.php index 8edb9ef9..bf11ad7f 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinition.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinition.php @@ -21,6 +21,11 @@ */ class ExportDefinition extends AbstractDataDefinition implements ExportDefinitionInterface { + /** + * @var bool + */ + public $enableInheritance = true; + /** * @var string */ @@ -54,6 +59,22 @@ public static function getByName($id) return $definitionEntry; } + /** + * @param bool $enableInheritance + */ + public function setEnableInheritance(bool $enableInheritance): void + { + $this->enableInheritance = $enableInheritance; + } + + /** + * @return bool + */ + public function isEnableInheritance(): bool + { + return $this->enableInheritance; + } + public function getFetcher() { return $this->fetcher; diff --git a/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php b/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php index f88fa881..ef15b1d4 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php @@ -121,6 +121,7 @@ public function save() 'mapping', 'runner', 'stopOnException', + 'enableInheritance', 'fetchUnpublished', 'failureNotificationDocument', 'successNotificationDocument', diff --git a/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php b/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php index 96dc6f28..7239c17e 100644 --- a/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php +++ b/src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php @@ -18,6 +18,16 @@ interface ExportDefinitionInterface extends DataDefinitionInterface { + /** + * @param bool $enableInheritance + */ + public function setEnableInheritance(bool $enableInheritance): void; + + /** + * @return bool + */ + public function isEnableInheritance(): bool; + /** * @return mixed */ diff --git a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml index 30e861c6..e131cfec 100755 --- a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml +++ b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml @@ -2,6 +2,10 @@ Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition: exclusion_policy: ALL xml_root_name: export_definition properties: + enableInheritance: + expose: true + type: boolean + groups: [Detailed] fetcher: expose: true type: string diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js index 1e1b2799..cd0dd0d5 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js @@ -124,6 +124,12 @@ pimcore.plugin.datadefinitions.export.item = Class.create(pimcore.plugin.datadef name: 'stopOnException', checked: this.data.stopOnException }, + { + fieldLabel: t('data_definitions_enable_inheritance'), + xtype: 'checkbox', + name: 'enableInheritance', + checked: this.data.enableInheritance + }, { fieldLabel: t('data_definitions_fetcher_objects_unpublished'), xtype: 'checkbox', diff --git a/src/DataDefinitionsBundle/Resources/translations/admin.en.yml b/src/DataDefinitionsBundle/Resources/translations/admin.en.yml index f784385e..3c577562 100644 --- a/src/DataDefinitionsBundle/Resources/translations/admin.en.yml +++ b/src/DataDefinitionsBundle/Resources/translations/admin.en.yml @@ -44,6 +44,7 @@ data_definitions_filter: 'Filter' data_definitions_runner: 'Runner' data_definitions_create_version: 'Create new Version on every Run' data_definitions_stop_on_exception: 'Stop on Exception' +data_definitions_enable_inheritance: 'Enable Inheritance' data_definitions_installed: 'ImportDefinitions has been installed' data_definitions_uninstalled: 'ImportDefinitions has been uninstalled' data_definitions_success_document: 'Success Notification Document'