Skip to content

Commit 2234a18

Browse files
committed
refactoring get erasure delay
1 parent ebabae0 commit 2234a18

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

Model/Config/Entity/Erasure.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Erasure
1818
{
1919
private const CONFIG_PATH_ERASURE_MAX_AGE = 'gdpr/erasure/entity_max_age';
2020
private const CONFIG_PATH_ERASURE_ALLOWED_STATES = 'gdpr/erasure/allowed_states';
21+
private const CONFIG_PATH_ERASURE_DELAY = 'gdpr/erasure/delay';
2122

2223
public function __construct(
2324
private ScopeConfigInterface $scopeConfig
@@ -51,4 +52,18 @@ public function getAllowedStatesToErase(int|string|null $website = null): array
5152
$website
5253
));
5354
}
55+
56+
/**
57+
* @param int|string|null $website
58+
*
59+
* @return int
60+
*/
61+
public function getDelay(int|string|null $website = null): int
62+
{
63+
return (int)$this->scopeConfig->getValue(
64+
self::CONFIG_PATH_ERASURE_DELAY,
65+
ScopeInterface::SCOPE_WEBSITE,
66+
$website
67+
);
68+
}
5469
}

Model/Customer/Notifier/MailSender.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,19 @@
1515
use Magento\Framework\Exception\NoSuchEntityException;
1616
use Magento\Framework\Mail\Template\TransportBuilder;
1717
use Magento\Store\Model\StoreManagerInterface;
18-
use Opengento\Gdpr\Model\EraseEntityManagement;
18+
use Opengento\Gdpr\Model\Config\Entity\Erasure;
1919
use Opengento\Gdpr\Model\Notifier\AbstractMailSender;
2020

2121
class MailSender extends AbstractMailSender implements SenderInterface
2222
{
23-
private View $customerViewHelper;
24-
25-
private StoreManagerInterface $storeManager;
26-
2723
public function __construct(
28-
protected EraseEntityManagement $entityManagement,
29-
View $customerViewHelper,
24+
private Erasure $erasureConfig,
25+
private View $customerViewHelper,
26+
private StoreManagerInterface $storeManager,
3027
TransportBuilder $transportBuilder,
3128
ScopeConfigInterface $scopeConfig,
32-
StoreManagerInterface $storeManager,
3329
array $configPaths
3430
) {
35-
$this->customerViewHelper = $customerViewHelper;
36-
$this->storeManager = $storeManager;
3731
parent::__construct($transportBuilder, $scopeConfig, $configPaths);
3832
}
3933

@@ -44,7 +38,7 @@ public function __construct(
4438
*/
4539
public function send(CustomerInterface $customer): void
4640
{
47-
$delay = $this->entityManagement->resolveErasureDelay();
41+
$delay = $this->erasureConfig->getDelay();
4842

4943
$storeId = $customer->getStoreId() === null ? null : (int)$customer->getStoreId();
5044
$vars = [

Model/EraseEntityManagement.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
use Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory;
1919
use Opengento\Gdpr\Api\EraseEntityManagementInterface;
2020
use Opengento\Gdpr\Api\EraseEntityRepositoryInterface;
21+
use Opengento\Gdpr\Model\Config\Entity\Erasure;
2122
use Opengento\Gdpr\Service\Erase\ProcessorFactory;
2223

2324
class EraseEntityManagement implements EraseEntityManagementInterface
2425
{
25-
private const CONFIG_PATH_ERASURE_DELAY = 'gdpr/erasure/delay';
26-
2726
public function __construct(
27+
private Erasure $erasureConfig,
2828
private EraseEntityInterfaceFactory $eraseEntityFactory,
2929
private EraseEntityRepositoryInterface $eraseRepository,
3030
private ProcessorFactory $processorFactory,
@@ -94,12 +94,7 @@ private function retrieveScheduledAt(): string
9494
{
9595
return $this->localeDate->gmtDate(
9696
DateTimeFormat::DATETIME_PHP_FORMAT,
97-
$this->resolveErasureDelay() * 60 + $this->localeDate->gmtTimestamp()
97+
$this->erasureConfig->getDelay() * 60 + $this->localeDate->gmtTimestamp()
9898
);
9999
}
100-
101-
public function resolveErasureDelay(): int
102-
{
103-
return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY);
104-
}
105100
}

0 commit comments

Comments
 (0)