From d2eed196ab8a8d9db8790f37eae43ded4c883f2f Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Sat, 24 Aug 2024 00:19:03 +0200 Subject: [PATCH] #145 - Use config path in default config values + fix email template reference --- Model/Notifier/AbstractMailSender.php | 58 ++------------ etc/adminhtml/system/notification.xml | 2 +- etc/config.xml | 105 +++++++------------------- 3 files changed, 34 insertions(+), 131 deletions(-) diff --git a/Model/Notifier/AbstractMailSender.php b/Model/Notifier/AbstractMailSender.php index 2e72786..c349b26 100644 --- a/Model/Notifier/AbstractMailSender.php +++ b/Model/Notifier/AbstractMailSender.php @@ -18,35 +18,18 @@ abstract class AbstractMailSender { - protected TransportBuilder $transportBuilder; - - private ScopeConfigInterface $scopeConfig; + private const CONFIG_PATH_ENABLED = 'gdpr/notification/enabled'; /** - * @var string[] - */ - private array $configPaths; - - /** - * @param TransportBuilder $transportBuilder - * @param ScopeConfigInterface $scopeConfig * @param string[] $configPaths */ public function __construct( - TransportBuilder $transportBuilder, - ScopeConfigInterface $scopeConfig, - array $configPaths - ) { - $this->transportBuilder = $transportBuilder; - $this->scopeConfig = $scopeConfig; - $this->configPaths = $configPaths; - } + protected TransportBuilder $transportBuilder, + private ScopeConfigInterface $scopeConfig, + private array $configPaths = [] + ) {} /** - * @param string $sendTo - * @param string|null $name [optional] Specify the to name. - * @param int|null $storeId [optional Current store ID is used by default. - * @param array $vars * @throws LocalizedException * @throws MailException */ @@ -77,10 +60,6 @@ protected function sendMail(string $sendTo, ?string $name = null, ?int $storeId } /** - * @param string $sendTo - * @param string|null $name [optional] Specify the to name. - * @param int|null $storeId [optional Current store ID is used by default. - * @param array $vars * @throws MailException */ 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 ->addTo($sendTo, $name); } - /** - * @param int|null $storeId [optional] Retrieves the value by scope. - * @return bool - */ protected function isAvailable(?int $storeId = null): bool { - return $this->scopeConfig->isSetFlag( - $this->configPaths['is_available'], - ScopeInterface::SCOPE_STORE, - $storeId - ); + return $this->scopeConfig->isSetFlag(self::CONFIG_PATH_ENABLED, ScopeInterface::SCOPE_STORE, $storeId) + && $this->scopeConfig->isSetFlag($this->configPaths['is_available'], ScopeInterface::SCOPE_STORE, $storeId); } - /** - * @param int|null $storeId [optional] Retrieves the value by scope. - * @return string - */ protected function getFrom(?int $storeId = null): string { return (string)$this->scopeConfig->getValue( @@ -118,10 +86,6 @@ protected function getFrom(?int $storeId = null): string ); } - /** - * @param int|null $storeId [optional] Retrieves the value by scope. - * @return array - */ protected function getCopyTo(?int $storeId = null): array { return explode( @@ -134,10 +98,6 @@ protected function getCopyTo(?int $storeId = null): array ); } - /** - * @param int|null $storeId [optional] Retrieves the value by scope. - * @return string - */ protected function getCopyMethod(?int $storeId = null): string { return (string)$this->scopeConfig->getValue( @@ -147,10 +107,6 @@ protected function getCopyMethod(?int $storeId = null): string ); } - /** - * @param int|null $storeId [optional] Retrieves the value by scope. - * @return string - */ protected function getTemplateIdentifier(?int $storeId = null): string { return (string)$this->scopeConfig->getValue( diff --git a/etc/adminhtml/system/notification.xml b/etc/adminhtml/system/notification.xml index 99ceef5..14652d0 100644 --- a/etc/adminhtml/system/notification.xml +++ b/etc/adminhtml/system/notification.xml @@ -19,7 +19,7 @@ It will enable the module features in the admin and frontend ui. Magento\Config\Model\Config\Source\Yesno - gdpr/notification/erase_enabled + gdpr/notification/enabled diff --git a/etc/config.xml b/etc/config.xml index 66748f1..ce77031 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -12,8 +12,6 @@ 0 privacy-policy-cookie-restriction-mode - - @@ -207,83 +205,32 @@ email - - 0 - - - - - 1 - - general - bcc - - - 1 - - general - bcc - - - - - 1 - - general - bcc - - - 1 - - general - bcc - - - - - 1 - - general - bcc - - - 1 - - general - bcc - - - - - - - 1 - - general - bcc - - - 1 - - general - bcc - - - - - 1 - - general - bcc - - - 1 - - general - bcc - - - + 0 + 1 + general + bcc + opengento_gdpr_notification_notification_erase_pending_template + opengento_gdpr_notification_notification_erase_pending_guest_template + 1 + general + bcc + opengento_gdpr_notification_notification_erase_succeeded_template + opengento_gdpr_notification_notification_erase_succeeded_guest_template + 1 + general + bcc + opengento_gdpr_notification_notification_erase_canceled_template + opengento_gdpr_notification_notification_erase_canceled_guest_template + 1 + general + bcc + opengento_gdpr_notification_notification_export_pending_template + opengento_gdpr_notification_notification_export_pending_guest_template + 1 + general + bcc + opengento_gdpr_notification_notification_export_ready_template + opengento_gdpr_notification_notification_export_ready_guest_template