Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <fabien@symfony.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Symfony\Component\Mailer\Exception;
13
 
14
use Symfony\Component\Mailer\Bridge;
15
use Symfony\Component\Mailer\Transport\Dsn;
16
 
17
/**
18
 * @author Konstantin Myakshin <molodchick@gmail.com>
19
 */
20
class UnsupportedSchemeException extends LogicException
21
{
22
    private const SCHEME_TO_PACKAGE_MAP = [
23
        'gmail' => [
24
            'class' => Bridge\Google\Transport\GmailTransportFactory::class,
25
            'package' => 'symfony/google-mailer',
26
        ],
27
        'infobip' => [
28
            'class' => Bridge\Infobip\Transport\InfobipTransportFactory::class,
29
            'package' => 'symfony/infobip-mailer',
30
        ],
31
        'mailgun' => [
32
            'class' => Bridge\Mailgun\Transport\MailgunTransportFactory::class,
33
            'package' => 'symfony/mailgun-mailer',
34
        ],
35
        'mailjet' => [
36
            'class' => Bridge\Mailjet\Transport\MailjetTransportFactory::class,
37
            'package' => 'symfony/mailjet-mailer',
38
        ],
39
        'mandrill' => [
40
            'class' => Bridge\Mailchimp\Transport\MandrillTransportFactory::class,
41
            'package' => 'symfony/mailchimp-mailer',
42
        ],
43
        'ohmysmtp' => [
44
            'class' => Bridge\OhMySmtp\Transport\OhMySmtpTransportFactory::class,
45
            'package' => 'symfony/oh-my-smtp-mailer',
46
        ],
47
        'postmark' => [
48
            'class' => Bridge\Postmark\Transport\PostmarkTransportFactory::class,
49
            'package' => 'symfony/postmark-mailer',
50
        ],
51
        'sendgrid' => [
52
            'class' => Bridge\Sendgrid\Transport\SendgridTransportFactory::class,
53
            'package' => 'symfony/sendgrid-mailer',
54
        ],
55
        'sendinblue' => [
56
            'class' => Bridge\Sendinblue\Transport\SendinblueTransportFactory::class,
57
            'package' => 'symfony/sendinblue-mailer',
58
        ],
59
        'ses' => [
60
            'class' => Bridge\Amazon\Transport\SesTransportFactory::class,
61
            'package' => 'symfony/amazon-mailer',
62
        ],
63
    ];
64
 
65
    public function __construct(Dsn $dsn, string $name = null, array $supported = [])
66
    {
67
        $provider = $dsn->getScheme();
68
        if (false !== $pos = strpos($provider, '+')) {
69
            $provider = substr($provider, 0, $pos);
70
        }
71
        $package = self::SCHEME_TO_PACKAGE_MAP[$provider] ?? null;
72
        if ($package && !class_exists($package['class'])) {
73
            parent::__construct(sprintf('Unable to send emails via "%s" as the bridge is not installed; try running "composer require %s".', $provider, $package['package']));
74
 
75
            return;
76
        }
77
 
78
        $message = sprintf('The "%s" scheme is not supported', $dsn->getScheme());
79
        if ($name && $supported) {
80
            $message .= sprintf('; supported schemes for mailer "%s" are: "%s"', $name, implode('", "', $supported));
81
        }
82
 
83
        parent::__construct($message.'.');
84
    }
85
}