diff --git a/Model/Customer/SourceProvider/FilterModifier.php b/Model/Customer/SourceProvider/IdleFilterModifier.php similarity index 96% rename from Model/Customer/SourceProvider/FilterModifier.php rename to Model/Customer/SourceProvider/IdleFilterModifier.php index 23984e1f..900a4996 100644 --- a/Model/Customer/SourceProvider/FilterModifier.php +++ b/Model/Customer/SourceProvider/IdleFilterModifier.php @@ -11,7 +11,7 @@ use Magento\Framework\Data\Collection; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface; -final class FilterModifier implements ModifierInterface +final class IdleFilterModifier implements ModifierInterface { public function apply(Collection $collection, Filter $filter): void { diff --git a/Model/Entity/SourceProvider/NotErasedFilterModifier.php b/Model/Entity/SourceProvider/NotErasedFilterModifier.php new file mode 100644 index 00000000..8f147535 --- /dev/null +++ b/Model/Entity/SourceProvider/NotErasedFilterModifier.php @@ -0,0 +1,52 @@ +entityType = $entityType; + $this->entityPrimaryField = $entityPrimaryField; + $this->mainTableAlias = $mainTableAlias; + } + + public function apply(Collection $collection, Filter $filter): void + { + if ($collection instanceof AbstractDb) { + $connection = $collection->getConnection(); + $select = $collection->getSelect(); + $select->joinLeft( + ['ogee' => $connection->getTableName('opengento_gdpr_erase_entity')], + sprintf(self::JOIN_ON, $this->mainTableAlias, $this->entityPrimaryField, $this->entityType), + [''] + ); + $select->where('ogee.erase_id IS NULL'); + } + } +} diff --git a/Model/EraseEntityManagement.php b/Model/EraseEntityManagement.php index d6575170..2c4b8526 100644 --- a/Model/EraseEntityManagement.php +++ b/Model/EraseEntityManagement.php @@ -33,9 +33,6 @@ final class EraseEntityManagement implements EraseEntityManagementInterface private ScopeConfigInterface $scopeConfig; - /** - * @var DateTime - */ private DateTime $localeDate; public function __construct( @@ -78,11 +75,7 @@ public function process(EraseEntityInterface $entity): EraseEntityInterface $eraser = $this->processorFactory->get($entity->getEntityType()); try { - if ($eraser->execute($entity->getEntityId())) { - return $this->success($entity); - } - - return $this->fail($entity); + return $eraser->execute($entity->getEntityId()) ? $this->success($entity) : $this->fail($entity); } catch (Exception $e) { $this->fail($entity, $e->getMessage()); throw new LocalizedException(new Phrase('Impossible to process the erasure: %1', [$e->getMessage()])); @@ -127,7 +120,7 @@ private function retrieveScheduledAt(): string ); } - public function resolveErasureDelay(): int + private function resolveErasureDelay(): int { return (int) $this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY, ScopeInterface::SCOPE_STORE); } diff --git a/Model/Order/SourceProvider/GuestModifier.php b/Model/Order/SourceProvider/GuestFilterModifier.php similarity index 94% rename from Model/Order/SourceProvider/GuestModifier.php rename to Model/Order/SourceProvider/GuestFilterModifier.php index 3f0451ba..43ddbe75 100644 --- a/Model/Order/SourceProvider/GuestModifier.php +++ b/Model/Order/SourceProvider/GuestFilterModifier.php @@ -14,7 +14,7 @@ use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface; -final class GuestModifier implements ModifierInterface +final class GuestFilterModifier implements ModifierInterface { private Config $config; diff --git a/etc/db_schema.xml b/etc/db_schema.xml index caf7d459..97deecd2 100644 --- a/etc/db_schema.xml +++ b/etc/db_schema.xml @@ -18,6 +18,10 @@ + diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json new file mode 100644 index 00000000..894d8cb3 --- /dev/null +++ b/etc/db_schema_whitelist.json @@ -0,0 +1,60 @@ +{ + "opengento_gdpr_erase_entity": { + "column": { + "erase_id": true, + "entity_id": true, + "entity_type": true, + "scheduled_at": true, + "state": true, + "status": true, + "message": true, + "erased_at": true + }, + "index": { + "OPENGENTO_GDPR_ERASE_ENTITY_ENTITY_ID": true, + "OPENGENTO_GDPR_ERASE_ENTITY_ENTITY_TYPE": true + }, + "constraint": { + "PRIMARY": true, + "OPENGENTO_GDPR_ERASE_ENTITY_ENTITY_ID_ENTITY_TYPE": true + } + }, + "opengento_gdpr_export_entity": { + "column": { + "export_id": true, + "entity_id": true, + "entity_type": true, + "file_name": true, + "file_path": true, + "created_at": true, + "exported_at": true, + "expired_at": true + }, + "index": { + "OPENGENTO_GDPR_EXPORT_ENTITY_ENTITY_ID": true, + "OPENGENTO_GDPR_EXPORT_ENTITY_ENTITY_TYPE": true + }, + "constraint": { + "PRIMARY": true + } + }, + "opengento_gdpr_action_entity": { + "column": { + "action_id": true, + "type": true, + "performed_from": true, + "performed_by": true, + "performed_at": true, + "state": true, + "message": true, + "parameters": true + }, + "index": { + "OPENGENTO_GDPR_ACTION_ENTITY_TYPE": true, + "OPENGENTO_GDPR_ACTION_ENTITY_STATE": true + }, + "constraint": { + "PRIMARY": true + } + } +} \ No newline at end of file diff --git a/etc/di.xml b/etc/di.xml index 82836cee..7e1a1864 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -765,10 +765,17 @@ Opengento\Gdpr\Model\Config\Source\Customer\EraseComponents + + + customer + e + + - Opengento\Gdpr\Model\Customer\SourceProvider\FilterModifier + Opengento\Gdpr\Model\Customer\SourceProvider\IdleFilterModifier + Opengento\Gdpr\Model\Customer\SourceProvider\NotErasedFilterModifier @@ -821,17 +828,23 @@ Opengento\Gdpr\Model\Config\Source\Order\EraseComponents - + created_at Magento\Sales\Api\Data\OrderInterface::UPDATED_AT + + + order + + - Opengento\Gdpr\Model\Order\SourceProvider\GuestModifier - Opengento\Gdpr\Model\Order\SourceProvider\FilterModifier + Opengento\Gdpr\Model\Order\SourceProvider\GuestFilterModifier + Opengento\Gdpr\Model\Order\SourceProvider\UpdatedAtFilterModifier + Opengento\Gdpr\Model\Order\SourceProvider\NotErasedFilterModifier diff --git a/view/base/layout/customer_privacy_export_personal_data.xml b/view/base/layout/customer_privacy_export_personal_data.xml index 7def026d..bee431ae 100644 --- a/view/base/layout/customer_privacy_export_personal_data.xml +++ b/view/base/layout/customer_privacy_export_personal_data.xml @@ -14,7 +14,7 @@ - + diff --git a/view/base/layout/customer_privacy_export_personal_data_renderers.xml b/view/base/layout/customer_privacy_export_personal_data_renderers.xml index 78a08f84..32da9bd4 100644 --- a/view/base/layout/customer_privacy_export_personal_data_renderers.xml +++ b/view/base/layout/customer_privacy_export_personal_data_renderers.xml @@ -7,6 +7,6 @@ --> - + diff --git a/view/frontend/layout/customer_privacy_erase.xml b/view/frontend/layout/customer_privacy_erase.xml index 09a65406..338896d6 100755 --- a/view/frontend/layout/customer_privacy_erase.xml +++ b/view/frontend/layout/customer_privacy_erase.xml @@ -17,7 +17,7 @@ - + Opengento\Gdpr\ViewModel\Customer\Privacy\SettingsDataProvider diff --git a/view/frontend/layout/customer_privacy_settings.xml b/view/frontend/layout/customer_privacy_settings.xml index 79254a7a..7a7ec39a 100755 --- a/view/frontend/layout/customer_privacy_settings.xml +++ b/view/frontend/layout/customer_privacy_settings.xml @@ -12,11 +12,11 @@ - + Opengento\Gdpr\ViewModel\Customer\Privacy\SettingsDataProvider - + Opengento\Gdpr\ViewModel\Customer\Privacy\ExportDataProvider Opengento\Gdpr\ViewModel\Customer\Privacy\ExportCustomerDataProvider @@ -24,7 +24,7 @@ - + Opengento\Gdpr\ViewModel\Customer\Privacy\EraseDataProvider Opengento\Gdpr\ViewModel\Customer\Privacy\EraseCustomerDataProvider diff --git a/view/frontend/layout/sales_guest_view.xml b/view/frontend/layout/sales_guest_view.xml index 45359a71..f5940aab 100644 --- a/view/frontend/layout/sales_guest_view.xml +++ b/view/frontend/layout/sales_guest_view.xml @@ -8,19 +8,19 @@ - + Opengento\Gdpr\ViewModel\Customer\Guest\ExportDataProvider - + Opengento\Gdpr\ViewModel\Customer\Guest\ExportDataProvider - + @@ -29,12 +29,12 @@ - + Opengento\Gdpr\ViewModel\Customer\Privacy\ExportDataProvider - + Opengento\Gdpr\ViewModel\Customer\Privacy\EraseDataProvider