Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..
Decoded Output download
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Notifier\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Notifier\Notification\Notification;
use Symfony\Component\Notifier\Notifier;
/**
* Sends a rejected message to the notifier.
*
* @author Fabien Potencier <[email protected]>
*/
class SendFailedMessageToNotifierListener implements EventSubscriberInterface
{
public function __construct(
private Notifier $notifier,
) {
}
public function onMessageFailed(WorkerMessageFailedEvent $event): void
{
if ($event->willRetry()) {
return;
}
$throwable = $event->getThrowable();
if ($throwable instanceof HandlerFailedException) {
$exceptions = $throwable->getWrappedExceptions();
$throwable = $exceptions[array_key_first($exceptions)];
}
$envelope = $event->getEnvelope();
$notification = Notification::fromThrowable($throwable)->importance(Notification::IMPORTANCE_HIGH);
$notification->subject(sprintf('A "%s" message has just failed: %s.', $envelope->getMessage()::class, $notification->getSubject()));
$this->notifier->send($notification, ...$this->notifier->getAdminRecipients());
}
public static function getSubscribedEvents(): array
{
return [
WorkerMessageFailedEvent::class => 'onMessageFailed',
];
}
}
?>
Did this file decode correctly?
Original Code
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Notifier\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Notifier\Notification\Notification;
use Symfony\Component\Notifier\Notifier;
/**
* Sends a rejected message to the notifier.
*
* @author Fabien Potencier <[email protected]>
*/
class SendFailedMessageToNotifierListener implements EventSubscriberInterface
{
public function __construct(
private Notifier $notifier,
) {
}
public function onMessageFailed(WorkerMessageFailedEvent $event): void
{
if ($event->willRetry()) {
return;
}
$throwable = $event->getThrowable();
if ($throwable instanceof HandlerFailedException) {
$exceptions = $throwable->getWrappedExceptions();
$throwable = $exceptions[array_key_first($exceptions)];
}
$envelope = $event->getEnvelope();
$notification = Notification::fromThrowable($throwable)->importance(Notification::IMPORTANCE_HIGH);
$notification->subject(sprintf('A "%s" message has just failed: %s.', $envelope->getMessage()::class, $notification->getSubject()));
$this->notifier->send($notification, ...$this->notifier->getAdminRecipients());
}
public static function getSubscribedEvents(): array
{
return [
WorkerMessageFailedEvent::class => 'onMessageFailed',
];
}
}
Function Calls
None |
Stats
MD5 | 70d1c85ca7f49e00028a0147ef2ce00b |
Eval Count | 0 |
Decode Time | 111 ms |