Compare commits

...
3 Commits
Author SHA1 Message Date
mcndave 1e7ac5db47 - Changed Laminas namespace 2023-03-30 18:24:33 +00:00
Dave Mc Nicoll 34b850c780 Bugfixes made on the interface 2022-02-25 16:41:49 +00:00
mcndave bee7e25935 - Work on SwiftMailer interface 2021-01-06 19:32:56 +00:00
3 changed files with 34 additions and 8 deletions

No files matched your search

+2
View File
@@ -8,5 +8,7 @@ interface MailerInterface
public function setFrom($from) : self; public function setFrom($from) : self;
public function attach(\Swift_Attachment $attachment) : self;
public function setTo($to) : self; public function setTo($to) : self;
} }
+28 -4
View File
@@ -8,11 +8,15 @@ class SwiftMailer implements MailerInterface
protected $transport; protected $transport;
protected $from; protected /*stringable*/ $from;
protected $to; protected /*stringable|array*/ $to;
protected $cc; protected /*stringable|array*/ $cc;
protected /*stringable|array*/ $bcc;
protected array $attachments = [];
public function __construct(EmailConfiguration $configuration) { public function __construct(EmailConfiguration $configuration) {
$this->emailConfiguration = $configuration; $this->emailConfiguration = $configuration;
@@ -28,10 +32,24 @@ class SwiftMailer implements MailerInterface
->setFrom( $this->from ) ->setFrom( $this->from )
->setTo( $this->to ) ->setTo( $this->to )
->setCC($this->cc ?? []) ->setCC($this->cc ?? [])
->setBCC($this->bcc ?? [])
->setBody( $message, $html ? 'text/html' : 'text/plain' ); ->setBody( $message, $html ? 'text/html' : 'text/plain' );
foreach ($this->attachments as $attachment) {
$swiftObj->attach($attachment);
}
$this->attachments = [];
return ( new \Swift_Mailer($this->transport) )->send($swiftObj); return ( new \Swift_Mailer($this->transport) )->send($swiftObj);
} }
public function attach(\Swift_Attachment $attachment) : self
{
$this->attachments[] = $attachment;
return $this;
}
public function setFrom(/*stringable|array*/ $from) : MailerInterface public function setFrom(/*stringable|array*/ $from) : MailerInterface
{ {
@@ -54,4 +72,10 @@ class SwiftMailer implements MailerInterface
return $this; return $this;
} }
public function setBCC(/*stringable|array*/ $bcc) : MailerInterface
{
$this->bcc = $bcc;
return $this;
}
} }
+4 -4
View File
@@ -9,10 +9,10 @@ use Psr\Http\Message\ResponseFactoryInterface,
Psr\Http\Server\MiddlewareInterface, Psr\Http\Server\MiddlewareInterface,
Psr\Http\Server\RequestHandlerInterface; Psr\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\Response, use Laminas\Diactoros\Response,
Zend\Diactoros\ServerRequest, Laminas\Diactoros\ServerRequest,
Zend\Diactoros\Stream, Laminas\Diactoros\Stream,
Zend\Diactoros\Uri; Laminas\Diactoros\Uri;
class JavascriptMiddleware implements MiddlewareInterface class JavascriptMiddleware implements MiddlewareInterface
{ {