-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log unsuccessful deliveries to the system log (#337)
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Terminal42\NotificationCenterBundle\EventListener; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener; | ||
use Terminal42\NotificationCenterBundle\Event\ReceiptEvent; | ||
|
||
#[AsEventListener] | ||
class LogUnsuccessfulDeliveries | ||
{ | ||
public function __construct(private readonly LoggerInterface|null $contaoErrorLogger) | ||
{ | ||
} | ||
|
||
public function __invoke(ReceiptEvent $event): void | ||
{ | ||
if (null === $this->contaoErrorLogger) { | ||
return; | ||
} | ||
|
||
$receipt = $event->receipt; | ||
|
||
if ($receipt->wasDelivered()) { | ||
return; | ||
} | ||
|
||
$exception = $receipt->getException(); | ||
|
||
$this->contaoErrorLogger->error($exception->getMessage(), ['exception' => $exception]); | ||
} | ||
} |