| Conditions | 4 |
| Paths | 1 |
| Total Lines | 37 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | public function register(Container $container) |
||
| 23 | { |
||
| 24 | $container->set('mailer_settings', []); |
||
| 25 | |||
| 26 | $container->set('swift_mailer', function ($c) { |
||
| 27 | $config = $c->get('mailer_settings')['transport']; |
||
| 28 | $transport = new Swift_SmtpTransport( |
||
| 29 | $config['host'], |
||
| 30 | $config['port'] |
||
| 31 | ); |
||
| 32 | if (isset($config['username'], $config['password'])) { |
||
| 33 | $transport->setUsername( |
||
| 34 | $config['username'] |
||
| 35 | ); |
||
| 36 | $transport->setPassword( |
||
| 37 | $config['password'] |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | if (isset($config['tls']) && true == $config['tls']) { |
||
| 41 | $transport->setEncryption( |
||
| 42 | 'tls' |
||
| 43 | ); |
||
| 44 | } |
||
| 45 | |||
| 46 | return new Swift_Mailer( |
||
| 47 | $transport |
||
| 48 | ); |
||
| 49 | }); |
||
| 50 | $container->set(Helper::class, function ($c) { |
||
| 51 | $config = $c->get('mailer_settings')['options']; |
||
| 52 | $swiftMailer = $c->get('swift_mailer'); |
||
| 53 | $twig = $c->get(Twig::class)->getEnvironment(); |
||
| 54 | |||
| 55 | return new Helper( |
||
| 56 | $config, |
||
| 57 | $swiftMailer, |
||
| 58 | $twig |
||
| 59 | ); |
||
| 63 |