Skip to content

Commit 5561056

Browse files
authored
Merge pull request #148 from kpitn/feat-add-missing-delay
add missing delay variable in email
2 parents ac18010 + 6e30512 commit 5561056

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

Model/Config/Entity/Erasure.php

Lines changed: 9 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,12 @@ public function getAllowedStatesToErase(int|string|null $website = null): array
5152
$website
5253
));
5354
}
55+
56+
/**
57+
* @return int
58+
*/
59+
public function getDelay(): int
60+
{
61+
return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY, ScopeInterface::SCOPE_WEBSITE);
62+
}
5463
}

Model/Customer/Notifier/MailSender.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +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\Config\Entity\Erasure;
1819
use Opengento\Gdpr\Model\Notifier\AbstractMailSender;
1920

2021
class MailSender extends AbstractMailSender implements SenderInterface
2122
{
22-
private View $customerViewHelper;
23-
24-
private StoreManagerInterface $storeManager;
25-
2623
public function __construct(
27-
View $customerViewHelper,
24+
private Erasure $erasureConfig,
25+
private View $customerViewHelper,
26+
private StoreManagerInterface $storeManager,
2827
TransportBuilder $transportBuilder,
2928
ScopeConfigInterface $scopeConfig,
30-
StoreManagerInterface $storeManager,
3129
array $configPaths
3230
) {
33-
$this->customerViewHelper = $customerViewHelper;
34-
$this->storeManager = $storeManager;
3531
parent::__construct($transportBuilder, $scopeConfig, $configPaths);
3632
}
3733

@@ -42,8 +38,11 @@ public function __construct(
4238
*/
4339
public function send(CustomerInterface $customer): void
4440
{
41+
$delay = $this->erasureConfig->getDelay();
42+
4543
$storeId = $customer->getStoreId() === null ? null : (int)$customer->getStoreId();
4644
$vars = [
45+
'delay' => $delay !== 0 ? $delay / 60 : 0,
4746
'customer' => $customer,
4847
'store' => $this->storeManager->getStore($customer->getStoreId()),
4948
'customer_data' => [

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-
private function resolveErasureDelay(): int
102-
{
103-
return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY);
104-
}
105100
}

view/frontend/email/erase_pending.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<tr class="email-summary">
2020
<td>
2121
<p>{{trans "We have received a request to erase the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
22-
<p>{{trans 'You can cancel the erase within %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
22+
<p>{{trans 'You can cancel the erase within %delay hours by <a href="%account_url">logging into your account</a>.' delay=$delay account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
2323
</td>
2424
</tr>
2525
<tr class="help-info">

view/frontend/email/erase_pending_guest.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<tr class="email-summary">
2020
<td>
2121
<p>{{trans "We have received a request to erase the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
22-
<p>{{trans 'You can cancel the erase within %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
22+
<p>{{trans 'You can cancel the erase within %delay hours by <a href="%account_url">logging into your account</a>.' delay=$delay account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
2323
</td>
2424
</tr>
2525
<tr class="help-info">

0 commit comments

Comments
 (0)