From 3a9750dc67480cf0d0168a06fff6c7fbc362aa10 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Fri, 23 Aug 2024 23:52:39 +0200 Subject: [PATCH] Remove unused imports --- Model/Config/Entity/Erasure.php | 5 +-- Model/Customer/Notifier/MailSender.php | 23 +++++----- .../SourceProvider/IdleFilterModifier.php | 4 +- Model/EraseEntityManagement.php | 6 +-- Model/Order/Notifier/MailSender.php | 45 ++++++------------- 5 files changed, 31 insertions(+), 52 deletions(-) diff --git a/Model/Config/Entity/Erasure.php b/Model/Config/Entity/Erasure.php index eb216d6..172cc58 100644 --- a/Model/Config/Entity/Erasure.php +++ b/Model/Config/Entity/Erasure.php @@ -53,11 +53,8 @@ public function getAllowedStatesToErase(int|string|null $website = null): array )); } - /** - * @return int - */ public function getDelay(): int { - return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY, ScopeInterface::SCOPE_WEBSITE); + return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY); } } diff --git a/Model/Customer/Notifier/MailSender.php b/Model/Customer/Notifier/MailSender.php index 6aa4bd0..f2379c0 100644 --- a/Model/Customer/Notifier/MailSender.php +++ b/Model/Customer/Notifier/MailSender.php @@ -39,17 +39,20 @@ public function __construct( public function send(CustomerInterface $customer): void { $delay = $this->erasureConfig->getDelay(); - $storeId = $customer->getStoreId() === null ? null : (int)$customer->getStoreId(); - $vars = [ - 'delay' => $delay !== 0 ? $delay / 60 : 0, - 'customer' => $customer, - 'store' => $this->storeManager->getStore($customer->getStoreId()), - 'customer_data' => [ - 'customer_name' => $this->customerViewHelper->getCustomerName($customer), - ], - ]; - $this->sendMail($customer->getEmail(), $this->customerViewHelper->getCustomerName($customer), $storeId, $vars); + $this->sendMail( + $customer->getEmail(), + $this->customerViewHelper->getCustomerName($customer), + $storeId, + [ + 'delay' => $delay !== 0 ? $delay / 60 : 0, + 'customer' => $customer, + 'store' => $this->storeManager->getStore($storeId), + 'customer_data' => [ + 'customer_name' => $this->customerViewHelper->getCustomerName($customer), + ] + ] + ); } } diff --git a/Model/Customer/SourceProvider/IdleFilterModifier.php b/Model/Customer/SourceProvider/IdleFilterModifier.php index a43a8f5..9763c47 100644 --- a/Model/Customer/SourceProvider/IdleFilterModifier.php +++ b/Model/Customer/SourceProvider/IdleFilterModifier.php @@ -15,9 +15,7 @@ class IdleFilterModifier implements ModifierInterface { - public function __construct( - private ErasureConfig $erasureConfig - ) {} + public function __construct(private ErasureConfig $erasureConfig) {} /** * @throws Exception diff --git a/Model/EraseEntityManagement.php b/Model/EraseEntityManagement.php index f66bccf..879413b 100644 --- a/Model/EraseEntityManagement.php +++ b/Model/EraseEntityManagement.php @@ -8,7 +8,6 @@ namespace Opengento\Gdpr\Model; use Exception; -use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; @@ -28,7 +27,6 @@ public function __construct( private EraseEntityInterfaceFactory $eraseEntityFactory, private EraseEntityRepositoryInterface $eraseRepository, private ProcessorFactory $processorFactory, - private ScopeConfigInterface $scopeConfig, private DateTime $localeDate ) {} @@ -40,7 +38,7 @@ public function create(int $entityId, string $entityType): EraseEntityInterface $entity->setEntityType($entityType); $entity->setState(EraseEntityInterface::STATE_PENDING); $entity->setStatus(EraseEntityInterface::STATUS_READY); - $entity->setScheduledAt($this->retrieveScheduledAt()); + $entity->setScheduledAt($this->createScheduledAt()); return $this->eraseRepository->save($entity); } @@ -90,7 +88,7 @@ private function fail(EraseEntityInterface $entity, ?string $message = null): Er return $this->eraseRepository->save($entity); } - private function retrieveScheduledAt(): string + private function createScheduledAt(): string { return $this->localeDate->gmtDate( DateTimeFormat::DATETIME_PHP_FORMAT, diff --git a/Model/Order/Notifier/MailSender.php b/Model/Order/Notifier/MailSender.php index 6bfda1b..bd7afab 100644 --- a/Model/Order/Notifier/MailSender.php +++ b/Model/Order/Notifier/MailSender.php @@ -14,55 +14,38 @@ use Magento\Sales\Api\Data\OrderInterface; use Magento\Store\Model\StoreManagerInterface; use Opengento\Gdpr\Model\Notifier\AbstractMailSender; -use Psr\Log\LoggerInterface; class MailSender extends AbstractMailSender implements SenderInterface { - /** - * @var LoggerInterface - */ - private LoggerInterface $logger; - - /** - * @var StoreManagerInterface - */ - private StoreManagerInterface $storeManager; - public function __construct( - LoggerInterface $logger, + private StoreManagerInterface $storeManager, TransportBuilder $transportBuilder, ScopeConfigInterface $scopeConfig, - StoreManagerInterface $storeManager, array $configPaths ) { - $this->logger = $logger; - $this->storeManager = $storeManager; parent::__construct($transportBuilder, $scopeConfig, $configPaths); } /** - * @inheritdoc * @throws LocalizedException * @throws MailException */ public function send(OrderInterface $order): void { $storeId = $order->getStoreId() === null ? null : (int)$order->getStoreId(); - $vars = [ - 'order' => $order, - 'billing' => $order->getBillingAddress(), - 'store' => $this->storeManager->getStore($order->getStoreId()), - 'customer_data' => [ - 'customer_name' => $order->getCustomerName(), - ], - ]; - - try { - $this->sendMail($order->getCustomerEmail(), $order->getCustomerName(), $storeId, $vars); - $this->logger->debug(__('GDPR Email Success')); - } catch (MailException $exc) { - $this->logger->error(__('GDPR Email Error: %1', $exc->getMessage())); - } + $this->sendMail( + $order->getCustomerEmail(), + $order->getCustomerName(), + $storeId, + [ + 'order' => $order, + 'billing' => $order->getBillingAddress(), + 'store' => $this->storeManager->getStore($storeId), + 'customer_data' => [ + 'customer_name' => $order->getCustomerName(), + ] + ] + ); } }