* initial commit
This commit is contained in:
25
src/App/Service/MailerServiceFactory.php
Normal file
25
src/App/Service/MailerServiceFactory.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Monolog\Logger;
|
||||
use Zend\Mail\Transport\File;
|
||||
use Zend\Mail\Transport\Smtp;
|
||||
|
||||
class MailerServiceFactory
|
||||
{
|
||||
|
||||
public function __invoke(ContainerInterface $container): MailerService
|
||||
{
|
||||
$config = $container->get('config');
|
||||
|
||||
/** @var Smtp|File $mailTransport */
|
||||
$mailTransport = new $config['mailer']['transportClass']();
|
||||
$transportOptions = new $config['mailer']['optionsClass']($config['mailer']['options']);
|
||||
$mailTransport->setOptions($transportOptions);
|
||||
/** @var Logger $logger */
|
||||
$logger = $container->get(Logger::class);
|
||||
return new MailerService($mailTransport, $config, $logger);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user