feat: integrate with MailJet API for newsletter registration
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Repository\NewsletterOptInConfirmationRepository;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'app:cleanup:newsletter-opt-in-requests',
|
||||
description: 'Removes expired pending newsletter double opt-in requests',
|
||||
)]
|
||||
class CleanupNewsletterOptInRequestsCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private readonly NewsletterOptInConfirmationRepository $confirmationRepository,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$deletedCount = $this->confirmationRepository->deleteExpiredPending();
|
||||
|
||||
if (0 === $deletedCount) {
|
||||
$io->success('No expired pending newsletter opt-in requests found.');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$this->logger->info('Deleted expired pending newsletter opt-in requests', [
|
||||
'count' => $deletedCount,
|
||||
]);
|
||||
|
||||
$io->success(sprintf('Deleted %d expired pending newsletter opt-in request(s).', $deletedCount));
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user