Skip to content

Commit 74d46a8

Browse files
ability to enable/disable value inheritance when exporting
1 parent 1a9e788 commit 74d46a8

File tree

8 files changed

+50
-0
lines changed

8 files changed

+50
-0
lines changed

src/DataDefinitionsBundle/Exporter/Exporter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Exception;
2222
use InvalidArgumentException;
2323
use Pimcore;
24+
use Pimcore\Model\DataObject;
2425
use Pimcore\Model\DataObject\Concrete;
2526
use Psr\Log\LoggerInterface;
2627
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -116,6 +117,9 @@ private function runExport(
116117
FetcherInterface $fetcher,
117118
ExportProviderInterface $provider
118119
) {
120+
$getInheritedValues = DataObject::getGetInheritedValues();
121+
DataObject::setGetInheritedValues($definition->isEnableInheritance());
122+
119123
UnpublishedHelper::hideUnpublished(
120124
function () use ($definition, $params, $total, $fetcher, $provider, $fetcherContext) {
121125
$count = 0;
@@ -180,6 +184,8 @@ function () use ($definition, $params, $total, $fetcher, $provider, $fetcherCont
180184
},
181185
false === $definition->isFetchUnpublished()
182186
);
187+
188+
DataObject::setGetInheritedValues($getInheritedValues);
183189
}
184190

185191
private function exportRow(

src/DataDefinitionsBundle/Form/Type/ExportDefinitionType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5252
->add('runner', ExportRunnerChoiceType::class)
5353
->add('name', TextType::class)
5454
->add('stopOnException', CheckboxType::class)
55+
->add('enableInheritance', CheckboxType::class)
5556
->add('fetchUnpublished', CheckboxType::class)
5657
->add('failureNotificationDocument', IntegerType::class)
5758
->add('successNotificationDocument', IntegerType::class)

src/DataDefinitionsBundle/Model/ExportDefinition.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
*/
2222
class ExportDefinition extends AbstractDataDefinition implements ExportDefinitionInterface
2323
{
24+
/**
25+
* @var bool
26+
*/
27+
public $enableInheritance = true;
28+
2429
/**
2530
* @var string
2631
*/
@@ -54,6 +59,22 @@ public static function getByName($id)
5459
return $definitionEntry;
5560
}
5661

62+
/**
63+
* @param bool $enableInheritance
64+
*/
65+
public function setEnableInheritance(bool $enableInheritance): void
66+
{
67+
$this->enableInheritance = $enableInheritance;
68+
}
69+
70+
/**
71+
* @return bool
72+
*/
73+
public function isEnableInheritance(): bool
74+
{
75+
return $this->enableInheritance;
76+
}
77+
5778
public function getFetcher()
5879
{
5980
return $this->fetcher;

src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public function save()
121121
'mapping',
122122
'runner',
123123
'stopOnException',
124+
'enableInheritance',
124125
'fetchUnpublished',
125126
'failureNotificationDocument',
126127
'successNotificationDocument',

src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818

1919
interface ExportDefinitionInterface extends DataDefinitionInterface
2020
{
21+
/**
22+
* @param bool $enableInheritance
23+
*/
24+
public function setEnableInheritance(bool $enableInheritance): void;
25+
26+
/**
27+
* @return bool
28+
*/
29+
public function isEnableInheritance(): bool;
30+
2131
/**
2232
* @return mixed
2333
*/

src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition:
22
exclusion_policy: ALL
33
xml_root_name: export_definition
44
properties:
5+
enableInheritance:
6+
expose: true
7+
type: boolean
8+
groups: [Detailed]
59
fetcher:
610
expose: true
711
type: string

src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ pimcore.plugin.datadefinitions.export.item = Class.create(pimcore.plugin.datadef
124124
name: 'stopOnException',
125125
checked: this.data.stopOnException
126126
},
127+
{
128+
fieldLabel: t('data_definitions_enable_inheritance'),
129+
xtype: 'checkbox',
130+
name: 'enableInheritance',
131+
checked: this.data.enableInheritance
132+
},
127133
{
128134
fieldLabel: t('data_definitions_fetcher_objects_unpublished'),
129135
xtype: 'checkbox',

src/DataDefinitionsBundle/Resources/translations/admin.en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ data_definitions_filter: 'Filter'
4444
data_definitions_runner: 'Runner'
4545
data_definitions_create_version: 'Create new Version on every Run'
4646
data_definitions_stop_on_exception: 'Stop on Exception'
47+
data_definitions_enable_inheritance: 'Enable Inheritance'
4748
data_definitions_installed: 'ImportDefinitions has been installed'
4849
data_definitions_uninstalled: 'ImportDefinitions has been uninstalled'
4950
data_definitions_success_document: 'Success Notification Document'

0 commit comments

Comments
 (0)