-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 4.4: Polyfill assertion method on Filesystem [Mailer] added message events logger fix typo
- Loading branch information
Showing
11 changed files
with
353 additions
and
6 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
12 changes: 12 additions & 0 deletions
12
src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer_debug.xml
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<service id="mailer.logger_message_listener" class="Symfony\Component\Mailer\EventListener\MessageLoggerListener"> | ||
<tag name="kernel.event_subscriber"/> | ||
</service> | ||
</services> | ||
</container> |
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,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mailer\Event; | ||
|
||
/** | ||
* @author Fabien Potencier <fabien@symfony.com> | ||
*/ | ||
class MessageEvents | ||
{ | ||
private $events = []; | ||
private $transports = []; | ||
|
||
public function add(MessageEvent $event): void | ||
{ | ||
$this->events[] = $event; | ||
$this->transports[$event->getTransportName()] = true; | ||
} | ||
|
||
public function getTransports(): array | ||
{ | ||
return array_keys($this->transports); | ||
} | ||
|
||
/** | ||
* @return MessageEvent[] | ||
*/ | ||
public function getEvents(string $name = null): array | ||
{ | ||
if (null === $name) { | ||
return $this->events; | ||
} | ||
|
||
$events = []; | ||
foreach ($this->events as $event) { | ||
if ($name === $event->getTransportName()) { | ||
$events[] = $event; | ||
} | ||
} | ||
|
||
return $events; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/Symfony/Component/Mailer/EventListener/MessageLoggerListener.php
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,57 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mailer\EventListener; | ||
|
||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\Mailer\Event\MessageEvent; | ||
use Symfony\Component\Mailer\Event\MessageEvents; | ||
use Symfony\Contracts\Service\ResetInterface; | ||
|
||
/** | ||
* Logs Messages. | ||
* | ||
* @author Fabien Potencier <fabien@symfony.com> | ||
*/ | ||
class MessageLoggerListener implements EventSubscriberInterface, ResetInterface | ||
{ | ||
private $events; | ||
|
||
public function __construct() | ||
{ | ||
$this->events = new MessageEvents(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function reset() | ||
{ | ||
$this->events = new MessageEvents(); | ||
} | ||
|
||
public function onMessage(MessageEvent $event): void | ||
{ | ||
$this->events->add($event); | ||
} | ||
|
||
public function getEvents(): MessageEvents | ||
{ | ||
return $this->events; | ||
} | ||
|
||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
MessageEvent::class => ['onMessage', -255], | ||
]; | ||
} | ||
} |
Oops, something went wrong.