Skip to content

Commit da12c7f

Browse files
committed
BounceProcessorPass
1 parent d179107 commit da12c7f

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

src/Core/ApplicationKernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ protected function build(ContainerBuilder $container): void
106106
{
107107
$container->setParameter('kernel.application_dir', $this->getApplicationDir());
108108
$container->addCompilerPass(new DoctrineMappingPass());
109+
$container->addCompilerPass(new BounceProcessorPass());
109110
}
110111

111112
/**

src/Core/BounceProcessorPass.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpList\Core\Core;
6+
7+
use PhpList\Core\Domain\Messaging\Service\BounceProcessingServiceInterface;
8+
use PhpList\Core\Domain\Messaging\Service\NativeBounceProcessingService;
9+
use PhpList\Core\Domain\Messaging\Service\WebklexBounceProcessingService;
10+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
11+
use Symfony\Component\DependencyInjection\ContainerBuilder;
12+
13+
class BounceProcessorPass implements CompilerPassInterface
14+
{
15+
public function process(ContainerBuilder $container): void
16+
{
17+
$iface = BounceProcessingServiceInterface::class;
18+
$native = NativeBounceProcessingService::class;
19+
$webklex = WebklexBounceProcessingService::class;
20+
21+
if (!$container->hasDefinition($native) || !$container->hasDefinition($webklex)) {
22+
return;
23+
}
24+
25+
$aliasTo = \extension_loaded('imap') ? $native : $webklex;
26+
27+
$container->setAlias($iface, $aliasTo)->setPublic(false);
28+
}
29+
}

src/Domain/Messaging/Command/ProcessBouncesCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4848
$io = new SymfonyStyle($input, $output);
4949

5050
if (!function_exists('imap_open')) {
51-
$io->error('IMAP extension not available. Cannot continue.');
52-
53-
return Command::FAILURE;
51+
$io->note('PHP IMAP extension not available. Falling back to Webklex IMAP where applicable.');
5452
}
5553

5654
$force = (bool)$input->getOption('force');

0 commit comments

Comments
 (0)