Skip to content

Commit

Permalink
Remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 committed Aug 23, 2024
1 parent 5561056 commit 3a9750d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 52 deletions.
5 changes: 1 addition & 4 deletions Model/Config/Entity/Erasure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
23 changes: 13 additions & 10 deletions Model/Customer/Notifier/MailSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]
]
);
}
}
4 changes: 1 addition & 3 deletions Model/Customer/SourceProvider/IdleFilterModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

class IdleFilterModifier implements ModifierInterface
{
public function __construct(
private ErasureConfig $erasureConfig
) {}
public function __construct(private ErasureConfig $erasureConfig) {}

/**
* @throws Exception
Expand Down
6 changes: 2 additions & 4 deletions Model/EraseEntityManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,7 +27,6 @@ public function __construct(
private EraseEntityInterfaceFactory $eraseEntityFactory,
private EraseEntityRepositoryInterface $eraseRepository,
private ProcessorFactory $processorFactory,
private ScopeConfigInterface $scopeConfig,
private DateTime $localeDate
) {}

Expand All @@ -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);
}
Expand Down Expand Up @@ -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,
Expand Down
45 changes: 14 additions & 31 deletions Model/Order/Notifier/MailSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]
]
);
}
}

0 comments on commit 3a9750d

Please sign in to comment.