10000 Update Array and Log transports · laravel/framework@b3ed86f · GitHub
[go: up one dir, main page]

Skip to content

Commit b3ed86f

Browse files
committed
Update Array and Log transports
1 parent 35216c2 commit b3ed86f

File tree

4 files changed

+35
-143
lines changed

4 files changed

+35
-143
lines changed

src/Illuminate/Mail/MailManager.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,10 @@ protected function createPostmarkTransport(array $config)
321321
'X-PM-Message-Stream' => $config['message_stream_id'],
322322
] : [];
323323

324-
return tap(new PostmarkTransport(
324+
return new PostmarkTransport(
325325
$config['token'] ?? $this->app['config']->get('services.postmark.token'),
326326
$headers
327-
), function ($transport) {
328-
$transport->registerPlugin(new ThrowExceptionOnFailurePlugin);
329-
});
327+
);
330328
}
331329

332330
/**

src/Illuminate/Mail/Transport/ArrayTransport.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace Illuminate\Mail\Transport;
44

55
use Illuminate\Support\Collection;
6-
use Swift_Mime_SimpleMessage;
6+
use Symfony\Component\Mailer\Envelope;
7+
use Symfony\Component\Mailer\SentMessage;
8+
use Symfony\Component\Mailer\Transport\TransportInterface;
9+
use Symfony\Component\Mime\RawMessage;
710

8-
class ArrayTransport extends Transport
11+
class ArrayTransport extends TransportInterface
912
{
1013
/**
1114
* The collection of Swift Messages.
@@ -27,13 +30,11 @@ public function __construct()
2730
/**
2831
* {@inheritdoc}
2932
*/
30-
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
33+
public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage
3134
{
32-
$this->beforeSendPerformed($message);
33-
3435
$this->messages[] = $message;
3536

36-
return $this->numberOfRecipients($message);
37+
return new SentMessage($message, $envelope);
3738
}
3839

3940
/**
@@ -55,4 +56,14 @@ public function flush()
5556
{
5657
return $this->messages = new Collection;
5758
}
59+
60+
/**
61+
* Get the string representation of the message.
62+
*
63+
* @return string
64+
*/
65+
public function __toString(): string
66+
{
67+
return 'array';
68+
}
5869
}

src/Illuminate/Mail/Transport/LogTransport.php

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
namespace Illuminate\Mail\Transport;
44

55
use Psr\Log\LoggerInterface;
6-
use Swift_Mime_SimpleMessage;
7-
use Swift_Mime_SimpleMimeEntity;
6+
use Symfony\Component\Mailer\Envelope;
7+
use Symfony\Component\Mailer\SentMessage;
8+
use Symfony\Component\Mailer\Transport\TransportInterface;
9+
use Symfony\Component\Mime\RawMessage;
810

9-
class LogTransport extends Transport
11+
class LogTransport extends TransportInterface
1012
{
1113
/**
1214
* The Logger instance.
@@ -29,41 +31,30 @@ public function __construct(LoggerInterface $logger)
2931
/**
3032
* {@inheritdoc}
3133
*/
32-
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
34+
public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage
3335
{
34-
$this->beforeSendPerformed($message);
36+
$this->logger->debug($message->toString());
3537

36-
$this->logger->debug($this->getMimeEntityString($message));
37-
38-
$this->sendPerformed($message);
39-
40-
return $this->numberOfRecipients($message);
38+
return new SentMessage($message, $envelope);
4139
}
4240

4341
/**
44-
* Get a loggable string out of a Swiftmailer entity.
42+
* Get the logger for the LogTransport instance.
4543
* 57AE
46-
* @param \Swift_Mime_SimpleMimeEntity $entity
47-
* @return string
44+
* @return \Psr\Log\LoggerInterface
4845
*/
49-
protected function getMimeEntityString(Swift_Mime_SimpleMimeEntity $entity)
46+
public function logger()
5047
{
51-
$string = (string) $entity->getHeaders().PHP_EOL.$entity->getBody();
52-
53-
foreach ($entity->getChildren() as $children) {
54-
$string .= PHP_EOL.PHP_EOL.$this->getMimeEntityString($children);
55-
}
56-
57-
return $string;
48+
return $this->logger;
5849
}
5950

6051
/**
61-
* Get the logger for the LogTransport instance.
52+
* Get the string representation of the transport.
6253
*
63-
* @return \Psr\Log\LoggerInterface
54+
* @return string
6455
*/
65-
public function logger()
56+
public function __toString(): string
6657
{
67-
return $this->logger;
58+
return 'log';
6859
}
6960
}

src/Illuminate/Mail/Transport/Transport.php

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0