Skip to content

Commit d2eed19

Browse files
committed
#145 - Use config path in default config values + fix email template reference
1 parent 3a9750d commit d2eed19

File tree

3 files changed

+34
-131
lines changed

3 files changed

+34
-131
lines changed

Model/Notifier/AbstractMailSender.php

+7-51
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,18 @@
1818

1919
abstract class AbstractMailSender
2020
{
21-
protected TransportBuilder $transportBuilder;
22-
23-
private ScopeConfigInterface $scopeConfig;
21+
private const CONFIG_PATH_ENABLED = 'gdpr/notification/enabled';
2422

2523
/**
26-
* @var string[]
27-
*/
28-
private array $configPaths;
29-
30-
/**
31-
* @param TransportBuilder $transportBuilder
32-
* @param ScopeConfigInterface $scopeConfig
3324
* @param string[] $configPaths
3425
*/
3526
public function __construct(
36-
TransportBuilder $transportBuilder,
37-
ScopeConfigInterface $scopeConfig,
38-
array $configPaths
39-
) {
40-
$this->transportBuilder = $transportBuilder;
41-
$this->scopeConfig = $scopeConfig;
42-
$this->configPaths = $configPaths;
43-
}
27+
protected TransportBuilder $transportBuilder,
28+
private ScopeConfigInterface $scopeConfig,
29+
private array $configPaths = []
30+
) {}
4431

4532
/**
46-
* @param string $sendTo
47-
* @param string|null $name [optional] Specify the to name.
48-
* @param int|null $storeId [optional Current store ID is used by default.
49-
* @param array $vars
5033
* @throws LocalizedException
5134
* @throws MailException
5235
*/
@@ -77,10 +60,6 @@ protected function sendMail(string $sendTo, ?string $name = null, ?int $storeId
7760
}
7861

7962
/**
80-
* @param string $sendTo
81-
* @param string|null $name [optional] Specify the to name.
82-
* @param int|null $storeId [optional Current store ID is used by default.
83-
* @param array $vars
8463
* @throws MailException
8564
*/
8665
protected function prepareMail(string $sendTo, ?string $name = null, ?int $storeId = null, array $vars = []): void
@@ -92,23 +71,12 @@ protected function prepareMail(string $sendTo, ?string $name = null, ?int $store
9271
->addTo($sendTo, $name);
9372
}
9473

95-
/**
96-
* @param int|null $storeId [optional] Retrieves the value by scope.
97-
* @return bool
98-
*/
9974
protected function isAvailable(?int $storeId = null): bool
10075
{
101-
return $this->scopeConfig->isSetFlag(
102-
$this->configPaths['is_available'],
103-
ScopeInterface::SCOPE_STORE,
104-
$storeId
105-
);
76+
return $this->scopeConfig->isSetFlag(self::CONFIG_PATH_ENABLED, ScopeInterface::SCOPE_STORE, $storeId)
77+
&& $this->scopeConfig->isSetFlag($this->configPaths['is_available'], ScopeInterface::SCOPE_STORE, $storeId);
10678
}
10779

108-
/**
109-
* @param int|null $storeId [optional] Retrieves the value by scope.
110-
* @return string
111-
*/
11280
protected function getFrom(?int $storeId = null): string
11381
{
11482
return (string)$this->scopeConfig->getValue(
@@ -118,10 +86,6 @@ protected function getFrom(?int $storeId = null): string
11886
);
11987
}
12088

121-
/**
122-
* @param int|null $storeId [optional] Retrieves the value by scope.
123-
* @return array
124-
*/
12589
protected function getCopyTo(?int $storeId = null): array
12690
{
12791
return explode(
@@ -134,10 +98,6 @@ protected function getCopyTo(?int $storeId = null): array
13498
);
13599
}
136100

137-
/**
138-
* @param int|null $storeId [optional] Retrieves the value by scope.
139-
* @return string
140-
*/
141101
protected function getCopyMethod(?int $storeId = null): string
142102
{
143103
return (string)$this->scopeConfig->getValue(
@@ -147,10 +107,6 @@ protected function getCopyMethod(?int $storeId = null): string
147107
);
148108
}
149109

150-
/**
151-
* @param int|null $storeId [optional] Retrieves the value by scope.
152-
* @return string
153-
*/
154110
protected function getTemplateIdentifier(?int $storeId = null): string
155111
{
156112
return (string)$this->scopeConfig->getValue(

etc/adminhtml/system/notification.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<label>Enabled</label>
2020
<comment>It will enable the module features in the admin and frontend ui.</comment>
2121
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
22-
<config_path>gdpr/notification/erase_enabled</config_path>
22+
<config_path>gdpr/notification/enabled</config_path>
2323
</field>
2424
</group>
2525
<group id="erase" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="20">

etc/config.xml

+26-79
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
<enabled>0</enabled>
1313
<page_id>privacy-policy-cookie-restriction-mode</page_id>
1414
</general>
15-
<action>
16-
</action>
1715
<anonymize>
1816
<customer_attributes>
1917
<email>
@@ -207,83 +205,32 @@
207205
<subscriber_attributes>email</subscriber_attributes>
208206
</export>
209207
<notification>
210-
<general>
211-
<enabled>0</enabled>
212-
</general>
213-
<erasure>
214-
<pending>
215-
<customer>
216-
<enabled>1</enabled>
217-
<template>gdpr_email_erase_pending_template</template>
218-
<identity>general</identity>
219-
<copy_method>bcc</copy_method>
220-
</customer>
221-
<order>
222-
<enabled>1</enabled>
223-
<template>gdpr_email_erase_pending_guest_template</template>
224-
<identity>general</identity>
225-
<copy_method>bcc</copy_method>
226-
</order>
227-
</pending>
228-
<succeeded>
229-
<customer>
230-
<enabled>1</enabled>
231-
<template>gdpr_email_erase_succeeded_template</template>
232-
<identity>general</identity>
233-
<copy_method>bcc</copy_method>
234-
</customer>
235-
<order>
236-
<enabled>1</enabled>
237-
<template>gdpr_email_erase_succeeded_guest_template</template>
238-
<identity>general</identity>
239-
<copy_method>bcc</copy_method>
240-
</order>
241-
</succeeded>
242-
<canceled>
243-
<customer>
244-
<enabled>1</enabled>
245-
<template>gdpr_email_erase_canceled_template</template>
246-
<identity>general</identity>
247-
<copy_method>bcc</copy_method>
248-
</customer>
249-
<order>
250-
<enabled>1</enabled>
251-
<template>gdpr_email_erase_canceled_guest_template</template>
252-
<identity>general</identity>
253-
<copy_method>bcc</copy_method>
254-
</order>
255-
</canceled>
256-
</erasure>
257-
<export>
258-
<pending>
259-
<customer>
260-
<enabled>1</enabled>
261-
<template>gdpr_email_export_pending_template</template>
262-
<identity>general</identity>
263-
<copy_method>bcc</copy_method>
264-
</customer>
265-
<order>
266-
<enabled>1</enabled>
267-
<template>gdpr_email_export_pending_guest_template</template>
268-
<identity>general</identity>
269-
<copy_method>bcc</copy_method>
270-
</order>
271-
</pending>
272-
<ready>
273-
<customer>
274-
<enabled>1</enabled>
275-
<template>gdpr_email_export_ready_template</template>
276-
<identity>general</identity>
277-
<copy_method>bcc</copy_method>
278-
</customer>
279-
<order>
280-
<enabled>1</enabled>
281-
<template>gdpr_email_export_ready_guest_template</template>
282-
<identity>general</identity>
283-
<copy_method>bcc</copy_method>
284-
</order>
285-
</ready>
286-
</export>
208+
<enabled>0</enabled>
209+
<erase_pending_enabled>1</erase_pending_enabled>
210+
<erase_pending_identity>general</erase_pending_identity>
211+
<erase_pending_copy_method>bcc</erase_pending_copy_method>
212+
<erase_pending_template>opengento_gdpr_notification_notification_erase_pending_template</erase_pending_template>
213+
<erase_pending_guest_template>opengento_gdpr_notification_notification_erase_pending_guest_template</erase_pending_guest_template>
214+
<erase_succeeded_enabled>1</erase_succeeded_enabled>
215+
<erase_succeeded_identity>general</erase_succeeded_identity>
216+
<erase_succeeded_copy_method>bcc</erase_succeeded_copy_method>
217+
<erase_succeeded_template>opengento_gdpr_notification_notification_erase_succeeded_template</erase_succeeded_template>
218+
<erase_succeeded_guest_template>opengento_gdpr_notification_notification_erase_succeeded_guest_template</erase_succeeded_guest_template>
219+
<erase_canceled_enabled>1</erase_canceled_enabled>
220+
<erase_canceled_identity>general</erase_canceled_identity>
221+
<erase_canceled_copy_method>bcc</erase_canceled_copy_method>
222+
<erase_canceled_template>opengento_gdpr_notification_notification_erase_canceled_template</erase_canceled_template>
223+
<erase_canceled_guest_template>opengento_gdpr_notification_notification_erase_canceled_guest_template</erase_canceled_guest_template>
224+
<export_pending_enabled>1</export_pending_enabled>
225+
<export_pending_identity>general</export_pending_identity>
226+
<export_pending_copy_method>bcc</export_pending_copy_method>
227+
<export_pending_template>opengento_gdpr_notification_notification_export_pending_template</export_pending_template>
228+
<export_pending_guest_template>opengento_gdpr_notification_notification_export_pending_guest_template</export_pending_guest_template>
229+
<export_ready_enabled>1</export_ready_enabled>
230+
<export_ready_identity>general</export_ready_identity>
231+
<export_ready_copy_method>bcc</export_ready_copy_method>
232+
<export_ready_template>opengento_gdpr_notification_notification_export_ready_template</export_ready_template>
233+
<export_ready_guest_template>opengento_gdpr_notification_notification_export_ready_guest_template</export_ready_guest_template>
287234
</notification>
288235
</gdpr>
289236
</default>

0 commit comments

Comments
 (0)