Skip to content

Commit

Permalink
Merge pull request #408 from dolmit-tanel-paaro/export-definition-ena…
Browse files Browse the repository at this point in the history
…ble-inheritance

Ability to enable/disable value inheritance when exporting
  • Loading branch information
dpfaffenbauer authored Jul 17, 2024
2 parents 1a9e788 + 74d46a8 commit 7ed48b3
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/DataDefinitionsBundle/Exporter/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -180,6 +184,8 @@ function () use ($definition, $params, $total, $fetcher, $provider, $fetcherCont
},
false === $definition->isFetchUnpublished()
);

DataObject::setGetInheritedValues($getInheritedValues);
}

private function exportRow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions src/DataDefinitionsBundle/Model/ExportDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
*/
class ExportDefinition extends AbstractDataDefinition implements ExportDefinitionInterface
{
/**
* @var bool
*/
public $enableInheritance = true;

/**
* @var string
*/
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/DataDefinitionsBundle/Model/ExportDefinition/Dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public function save()
'mapping',
'runner',
'stopOnException',
'enableInheritance',
'fetchUnpublished',
'failureNotificationDocument',
'successNotificationDocument',
Expand Down
10 changes: 10 additions & 0 deletions src/DataDefinitionsBundle/Model/ExportDefinitionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 7ed48b3

Please sign in to comment.