getSupportedSchemes example

use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
use Symfony\Component\Notifier\Transport\Dsn;

final class EsendexTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): EsendexTransport
    {
        $scheme = $dsn->getScheme();

        if ('esendex' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'esendex', $this->getSupportedSchemes());
        }

        $email = $this->getUser($dsn);
        $password = $this->getPassword($dsn);
        $accountReference = $dsn->getRequiredOption('accountreference');
        $from = $dsn->getRequiredOption('from');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new EsendexTransport($email$password$accountReference$from$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    
protected $dispatcher;
    protected $client;

    public function __construct(EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null)
    {
        $this->dispatcher = $dispatcher;
        $this->client = $client;
    }

    public function supports(Dsn $dsn): bool
    {
        return \in_array($dsn->getScheme()$this->getSupportedSchemes());
    }

    /** * @return string[] */
    abstract protected function getSupportedSchemes(): array;

    protected function getUser(Dsn $dsn): string
    {
        return $dsn->getUser() ?? throw new IncompleteDsnException('User is not set.', $dsn->getScheme().'://'.$dsn->getHost());
    }

    
if (null !== $transport) {
            $messageStream = $dsn->getOption('message_stream');

            if (null !== $messageStream) {
                $transport->setMessageStream($messageStream);
            }

            return $transport;
        }

        throw new UnsupportedSchemeException($dsn, 'postmark', $this->getSupportedSchemes());
    }

    protected function getSupportedSchemes(): array
    {
        return ['postmark', 'postmark+api', 'postmark+smtp', 'postmark+smtps'];
    }
}
/** * @author Thibault Buathier <thibault.buathier@gmail.com> */
final class SmsFactorTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): SmsFactorTransport
    {
        $scheme = $dsn->getScheme();

        if ('sms-factor' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'sms-factor', $this->getSupportedSchemes());
        }

        $tokenApi = $this->getUser($dsn);
        $sender = $dsn->getOption('sender');
        $pushType = $this->getPushType($dsn);

        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new SmsFactorTransport($tokenApi$sender$pushType$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    
/** * @author Adrian Nguyen <vuphuong87@gmail.com> */
final class MessageMediaTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): MessageMediaTransport
    {
        $scheme = $dsn->getScheme();

        if ('messagemedia' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'messagemedia', $this->getSupportedSchemes());
        }

        $apiKey = $this->getUser($dsn);
        $apiSecret = $this->getPassword($dsn);
        $from = $dsn->getOption('from');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new MessageMediaTransport($apiKey$apiSecret$from$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
use Symfony\Component\Notifier\Transport\Dsn;

/** * @author Jon Gotlin <jon@jon.se> */
final class FortySixElksTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): FortySixElksTransport
    {
        if ('forty-six-elks' !== $dsn->getScheme()) {
            throw new UnsupportedSchemeException($dsn, 'forty-six-elks', $this->getSupportedSchemes());
        }

        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $from = $dsn->getRequiredOption('from');

        return (new FortySixElksTransport($this->getUser($dsn)$this->getPassword($dsn)$from$this->client, $this->dispatcher))->setHost($host)->setPort($dsn->getPort());
    }

    protected function getSupportedSchemes(): array
    {
        return ['forty-six-elks'];
    }
/** * @author Fabien Potencier <fabien@symfony.com> */
final class NullTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): NullTransport
    {
        if ('null' === $dsn->getScheme()) {
            return new NullTransport($this->dispatcher);
        }

        throw new UnsupportedSchemeException($dsn, 'null', $this->getSupportedSchemes());
    }

    protected function getSupportedSchemes(): array
    {
        return ['null'];
    }
}
/** * @author Mohammad Emran Hasan <phpfour@gmail.com> */
final class ZulipTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): ZulipTransport
    {
        $scheme = $dsn->getScheme();

        if ('zulip' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'zulip', $this->getSupportedSchemes());
        }

        $email = $this->getUser($dsn);
        $token = $this->getPassword($dsn);
        $channel = $dsn->getRequiredOption('channel');
        $host = $dsn->getHost();
        $port = $dsn->getPort();

        return (new ZulipTransport($email$token$channel$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    
/** * @author Jeroen Spee <https://github.com/Jeroeny> */
final class FirebaseTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): FirebaseTransport
    {
        $scheme = $dsn->getScheme();

        if ('firebase' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'firebase', $this->getSupportedSchemes());
        }

        $token = sprintf('%s:%s', $this->getUser($dsn)$this->getPassword($dsn));
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new FirebaseTransport($token$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        
/** * @author Vasilij Duško <vasilij@prado.lt> */
final class SendberryTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): SendberryTransport
    {
        $scheme = $dsn->getScheme();

        if ('sendberry' !== $scheme) {
            throw new UnsupportedSchemeException($dsn, 'sendberry', $this->getSupportedSchemes());
        }

        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new SendberryTransport($this->getUser($dsn)$this->getPassword($dsn)$dsn->getRequiredOption('auth_key')$dsn->getRequiredOption('from')$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return ['sendberry'];
    }
private const SCHEME = 'novu';

    protected function getSupportedSchemes(): array
    {
        return [self::SCHEME];
    }

    public function create(Dsn $dsn): NovuTransport
    {
        $scheme = $dsn->getScheme();
        if (self::SCHEME !== $scheme) {
            throw new UnsupportedSchemeException($dsn, self::SCHEME, $this->getSupportedSchemes());
        }

        $key = $this->getUser($dsn);
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new NovuTransport($key$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }
}
/** * @author Ahmed Ghanem <ahmedghanem7361@gmail.com> */
final class GoIpTransportFactory extends AbstractTransportFactory
{
    private const SCHEME_NAME = 'goip';

    public function create(Dsn $dsn): GoIpTransport
    {
        if (self::SCHEME_NAME !== $dsn->getScheme()) {
            throw new UnsupportedSchemeException($dsn, self::SCHEME_NAME, $this->getSupportedSchemes());
        }

        $username = $this->getUser($dsn);
        $password = $this->getPassword($dsn);

        if (=== ($simSlot = (int) $dsn->getRequiredOption('sim_slot'))) {
            throw new InvalidArgumentException(sprintf('The provided SIM-Slot: "%s" is not valid.', $simSlot));
        }

        return (new GoIpTransport($username$password$simSlot$this->client, $this->dispatcher))
            ->setHost($dsn->getHost())
            
if ('mailpace+api' === $scheme) {
            $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
            $port = $dsn->getPort();

            return (new MailPaceApiTransport($this->getUser($dsn)$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('mailpace+smtp' === $scheme || 'mailpace+smtps' === $scheme || 'mailpace' === $scheme) {
            return new MailPaceSmtpTransport($this->getUser($dsn)$this->dispatcher, $this->logger);
        }

        throw new UnsupportedSchemeException($dsn, 'mailpace', $this->getSupportedSchemes());
    }

    protected function getSupportedSchemes(): array
    {
        return ['mailpace', 'mailpace+api', 'mailpace+smtp', 'mailpace+smtps'];
    }
}

final class TermiiTransportFactory extends AbstractTransportFactory
{
    private const TRANSPORT_SCHEME = 'termii';

    public function create(Dsn $dsn): TermiiTransport
    {
        $scheme = $dsn->getScheme();

        if (self::TRANSPORT_SCHEME !== $scheme) {
            throw new UnsupportedSchemeException($dsn, self::TRANSPORT_SCHEME, $this->getSupportedSchemes());
        }

        $apiKey = $this->getUser($dsn);
        $from = $dsn->getRequiredOption('from');
        $channel = $dsn->getRequiredOption('channel');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new TermiiTransport($apiKey$from$channel$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    

final class SmsmodeTransportFactory extends AbstractTransportFactory
{
    private const TRANSPORT_SCHEME = 'smsmode';

    public function create(Dsn $dsn): SmsmodeTransport
    {
        $scheme = $dsn->getScheme();

        if (self::TRANSPORT_SCHEME !== $scheme) {
            throw new UnsupportedSchemeException($dsn, self::TRANSPORT_SCHEME, $this->getSupportedSchemes());
        }

        $apiKey = $this->getUser($dsn);
        $from = $dsn->getRequiredOption('from');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new SmsmodeTransport($apiKey$from$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
Home | Imprint | This part of the site doesn't use cookies.