-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #128 erase already erased entities result in duplicated entries
- Loading branch information
1 parent
970caf8
commit c8ae934
Showing
12 changed files
with
148 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright © OpenGento, All rights reserved. | ||
* See LICENSE bundled with this library for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Opengento\Gdpr\Model\Entity\SourceProvider; | ||
|
||
use Magento\Framework\Api\Filter; | ||
use Magento\Framework\Data\Collection; | ||
use Magento\Framework\Data\Collection\AbstractDb; | ||
use function sprintf; | ||
|
||
final class NotErasedFilterModifier implements ModifierInterface | ||
{ | ||
private const DEFAULT_PRIMARY_FIELD = 'entity_id'; | ||
|
||
private const DEFAULT_MAIN_TABLE_ALIAS = 'main_table'; | ||
|
||
private const JOIN_ON = '%s.%s=ogee.entity_id AND ogee.entity_type="%s"'; | ||
|
||
private string $entityType; | ||
|
||
private string $entityPrimaryField; | ||
|
||
private string $mainTableAlias; | ||
|
||
public function __construct( | ||
string $entityType, | ||
string $entityPrimaryField = self::DEFAULT_PRIMARY_FIELD, | ||
string $mainTableAlias = self::DEFAULT_MAIN_TABLE_ALIAS | ||
) { | ||
$this->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'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters