Skip to content

Commit

Permalink
Merge branch 'swift_array_transport' of https://github.com/sileence/l…
Browse files Browse the repository at this point in the history
…aravel-framework into sileence-swift_array_transport
  • Loading branch information
taylorotwell committed Dec 22, 2016
2 parents f41ff23 + 6a905c7 commit a5dd235
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/Illuminate/Mail/Transport/ArrayTransport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Illuminate\Mail\Transport;

use Swift_Mime_Message;
use Illuminate\Support\Collection;

class ArrayTransport extends Transport
{
/**
* The collection of Swift Messages.
*
* @var \Illuminate\Support\Collection
*/
protected $messages;

/**
* Create a new array transport instance.
*
* @return void
*/
public function __construct()
{
$this->messages = new Collection;
}

/**
* {@inheritdoc}
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
$this->beforeSendPerformed($message);

$this->messages[] = $message;

return $this->numberOfRecipients($message);
}

/**
* Return the collection of messages.
*
* @return \Illuminate\Support\Collection
*/
public function getMessages()
{
return $this->messages;
}

public function clearMessages()
{
return $this->messages = new Collection;
}
}
9 changes: 9 additions & 0 deletions src/Illuminate/Mail/TransportManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Swift_SmtpTransport as SmtpTransport;
use Illuminate\Mail\Transport\LogTransport;
use Illuminate\Mail\Transport\SesTransport;
use Illuminate\Mail\Transport\ArrayTransport;
use Illuminate\Mail\Transport\MailgunTransport;
use Illuminate\Mail\Transport\MandrillTransport;
use Illuminate\Mail\Transport\SparkPostTransport;
Expand Down Expand Up @@ -150,6 +151,14 @@ protected function createLogDriver()
return new LogTransport($this->app->make('Psr\Log\LoggerInterface'));
}

/**
* Create an instance of the Array Swift Transport Driver.
*/
protected function createArrayDriver()
{
return new ArrayTransport();
}

/**
* Get a fresh Guzzle HTTP client instance.
*
Expand Down

0 comments on commit a5dd235

Please sign in to comment.