1818use PhpList \Core \Domain \Subscription \Model \Subscriber ;
1919use Psr \Log \LoggerInterface ;
2020use Symfony \Component \Console \Output \OutputInterface ;
21+ use Symfony \Contracts \Translation \TranslatorInterface ;
2122use Throwable ;
2223
2324/**
@@ -33,6 +34,7 @@ class CampaignProcessor
3334 private UserMessageRepository $ userMessageRepository ;
3435 private MaxProcessTimeLimiter $ timeLimiter ;
3536 private RequeueHandler $ requeueHandler ;
37+ private TranslatorInterface $ translator ;
3638
3739 public function __construct (
3840 RateLimitedCampaignMailer $ mailer ,
@@ -42,7 +44,8 @@ public function __construct(
4244 LoggerInterface $ logger ,
4345 UserMessageRepository $ userMessageRepository ,
4446 MaxProcessTimeLimiter $ timeLimiter ,
45- RequeueHandler $ requeueHandler
47+ RequeueHandler $ requeueHandler ,
48+ TranslatorInterface $ translator ,
4649 ) {
4750 $ this ->mailer = $ mailer ;
4851 $ this ->entityManager = $ entityManager ;
@@ -52,6 +55,7 @@ public function __construct(
5255 $ this ->userMessageRepository = $ userMessageRepository ;
5356 $ this ->timeLimiter = $ timeLimiter ;
5457 $ this ->requeueHandler = $ requeueHandler ;
58+ $ this ->translator = $ translator ;
5559 }
5660
5761 public function process (Message $ campaign , ?OutputInterface $ output = null ): void
@@ -82,7 +86,9 @@ public function process(Message $campaign, ?OutputInterface $output = null): voi
8286 if (!filter_var ($ subscriber ->getEmail (), FILTER_VALIDATE_EMAIL )) {
8387 $ this ->updateUserMessageStatus ($ userMessage , UserMessageStatus::InvalidEmailAddress);
8488 $ this ->unconfirmSubscriber ($ subscriber );
85- $ output ?->writeln('Invalid email, marking unconfirmed: ' . $ subscriber ->getEmail ());
89+ $ output ?->writeln($ this ->translator ->trans ('Invalid email, marking unconfirmed: %email% ' , [
90+ '%email% ' => $ subscriber ->getEmail (),
91+ ]));
8692 continue ;
8793 }
8894
@@ -98,7 +104,9 @@ public function process(Message $campaign, ?OutputInterface $output = null): voi
98104 'subscriber_id ' => $ subscriber ->getId (),
99105 'campaign_id ' => $ campaign ->getId (),
100106 ]);
101- $ output ?->writeln('Failed to send to: ' . $ subscriber ->getEmail ());
107+ $ output ?->writeln($ this ->translator ->trans ('Failed to send to: %email% ' , [
108+ '%email% ' => $ subscriber ->getEmail (),
109+ ]));
102110 }
103111 }
104112
0 commit comments