setHost example

public function create(Dsn $dsn): ContactEveryoneTransport
    {
        if ('contact-everyone' !== $dsn->getScheme()) {
            throw new UnsupportedSchemeException($dsn, 'contact-everyone', $this->getSupportedSchemes());
        }

        $token = $this->getUser($dsn);
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $diffusionName = $dsn->getOption('diffusionname');
        $category = $dsn->getOption('category');

        return (new ContactEveryoneTransport($token$diffusionName$category$this->client, $this->dispatcher))->setHost($host)->setPort($dsn->getPort());
    }

    protected function getSupportedSchemes(): array
    {
        return ['contact-everyone'];
    }
}
use Symfony\Component\Notifier\Tests\Transport\DummyMessage;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;

/** * @group legacy */
final class SendinblueTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): SendinblueTransport
    {
        return (new SendinblueTransport('api-key', '0611223344', $client ?? new MockHttpClient()))->setHost('host.test');
    }

    public static function toStringProvider(): iterable
    {
        yield ['sendinblue://host.test?sender=0611223344', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
    }

    


        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $topic = substr($dsn->getPath(), 1);

        if (\in_array($dsn->getOption('secureHttp', true)[0, false, 'false', 'off', 'no'])) {
            $secureHttp = false;
        } else {
            $secureHttp = true;
        }

        $transport = (new NtfyTransport($topic$secureHttp))->setHost($host);
        if (!empty($port = $dsn->getPort())) {
            $transport->setPort($port);
        }

        if (!empty($user = $dsn->getUser()) && !empty($password = $dsn->getPassword())) {
            $transport->setUser($user);
            $transport->setPassword($password);
        }

        return $transport;
    }

    
<?php
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

return function Dstring $format) {
    $expectedRoutes = new RouteCollection();
    $expectedRoutes->add('imported.en', $route = new Route('/en/example'));
    $route->setHost('www.example.com');
    $route->setRequirement('_locale', 'en');
    $route->setDefault('_locale', 'en');
    $route->setDefault('_canonical_route', 'imported');
    $route->setDefault('_controller', 'ImportedController::someAction');
    $expectedRoutes->add('imported.nl', $route = new Route('/nl/voorbeeld'));
    $route->setHost('www.example.nl');
    $route->setRequirement('_locale', 'nl');
    $route->setDefault('_locale', 'nl');
    $route->setDefault('_canonical_route', 'imported');
    $route->setDefault('_controller', 'ImportedController::someAction');
    $expectedRoutes->add('imported_not_localized.en', $route = new Route('/en/here'));
    
public static function createProvider(): iterable
    {
        $logger = new NullLogger();

        yield [
            new Dsn('ohmysmtp+api', 'default', self::USER),
            new OhMySmtpApiTransport(self::USER, new MockHttpClient(), null, $logger),
        ];

        yield [
            new Dsn('ohmysmtp+api', 'example.com', self::USER, '', 8080),
            (new OhMySmtpApiTransport(self::USER, new MockHttpClient(), null, $logger))->setHost('example.com')->setPort(8080),
        ];

        yield [
            new Dsn('ohmysmtp', 'default', self::USER),
            new OhMySmtpSmtpTransport(self::USER, null, $logger),
        ];

        yield [
            new Dsn('ohmysmtp+smtp', 'default', self::USER),
            new OhMySmtpSmtpTransport(self::USER, null, $logger),
        ];

        

        $expectedCollection->add('controller_class', (new Route('/controller'))
            ->setDefaults(['_controller' => ['Acme\MyApp\MyController', 'myAction']])
        );
        $expectedCollection->add('c_root', (new Route('/sub/pub/'))
            ->setRequirements(['id' => '\d+'])
        );
        $expectedCollection->add('c_bar', (new Route('/sub/pub/bar'))
            ->setRequirements(['id' => '\d+'])
        );
        $expectedCollection->add('c_pub_buz', (new Route('/sub/pub/buz'))
            ->setHost('host')
            ->setRequirements(['id' => '\d+'])
        );
        $expectedCollection->add('z_c_root', new Route('/zub/pub/'));
        $expectedCollection->add('z_c_bar', new Route('/zub/pub/bar'));
        $expectedCollection->add('z_c_pub_buz', (new Route('/zub/pub/buz'))->setHost('host'));
        $expectedCollection->add('r_root', new Route('/bus'));
        $expectedCollection->add('r_bar', new Route('/bus/bar/'));
        $expectedCollection->add('ouf', (new Route('/ouf'))
            ->setSchemes(['https'])
            ->setMethods(['GET'])
            ->setDefaults(['id' => 0])
        );
throw new UnsupportedSchemeException($dsn, self::TRANSPORT_SCHEME, $this->getSupportedSchemes());
        }
        $apiUsername = $this->getUser($dsn);
        $apiKey = $this->getPassword($dsn);
        $from = $dsn->getOption('from');
        $source = $dsn->getOption('source');
        $listId = $dsn->getOption('list_id');
        $fromEmail = $dsn->getOption('from_email');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $port = $dsn->getPort();

        return (new ClickSendTransport($apiUsername$apiKey$from$source$listId$fromEmail$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return [self::TRANSPORT_SCHEME];
    }
}
public function create(Dsn $dsn): PagerDutyTransport
    {
        $scheme = $dsn->getScheme();

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

        $apiToken = $this->getUser($dsn);
        $host = $this->getHost($dsn);

        return (new PagerDutyTransport($apiToken$this->client, $this->dispatcher))->setHost($host);
    }

    protected function getSupportedSchemes(): array
    {
        return ['pagerduty'];
    }

    private function getHost(Dsn $dsn): string
    {
        $host = $dsn->getHost();
        if ('default' === $host) {
            
$this->assertSame([]$collection->all(), '->remove() accepts an array and can remove multiple routes at once');
    }

    public function testSetHost()
    {
        $collection = new RouteCollection();
        $routea = new Route('/a');
        $routeb = new Route('/b', [][][], '{locale}.example.net');
        $collection->add('a', $routea);
        $collection->add('b', $routeb);

        $collection->setHost('{locale}.example.com');

        $this->assertEquals('{locale}.example.com', $routea->getHost());
        $this->assertEquals('{locale}.example.com', $routeb->getHost());
    }

    public function testSetCondition()
    {
        $collection = new RouteCollection();
        $routea = new Route('/a');
        $routeb = new Route('/b', [][][], '{locale}.example.net', [][], 'context.getMethod() == "GET"');
        $collection->add('a', $routea);
        
$currentHost = $context->getHost();
        $currentScheme = $context->getScheme();
        $currentHttpPort = $context->getHttpPort();
        $currentHttpsPort = $context->getHttpsPort();
        $currentPathInfo = $context->getPathInfo();
        $currentQueryString = $context->getQueryString();

        /* @var RouterContextStamp $contextStamp */
        $context
            ->setBaseUrl($contextStamp->getBaseUrl())
            ->setMethod($contextStamp->getMethod())
            ->setHost($contextStamp->getHost())
            ->setScheme($contextStamp->getScheme())
            ->setHttpPort($contextStamp->getHttpPort())
            ->setHttpsPort($contextStamp->getHttpsPort())
            ->setPathInfo($contextStamp->getPathInfo())
            ->setQueryString($contextStamp->getQueryString())
        ;

        try {
            return $stack->next()->handle($envelope$stack);
        } finally {
            $context
                
$scheme = $dsn->getScheme();

        if ('fakechat+email' === $scheme) {
            if (null === $this->mailer) {
                $this->throwMissingDependencyException($scheme, MailerInterface::class, 'symfony/mailer');
            }

            $mailerTransport = $dsn->getHost();
            $to = $dsn->getRequiredOption('to');
            $from = $dsn->getRequiredOption('from');

            return (new FakeChatEmailTransport($this->mailer, $to$from))->setHost($mailerTransport);
        }

        if ('fakechat+logger' === $scheme) {
            if (null === $this->logger) {
                $this->throwMissingDependencyException($scheme, LoggerInterface::class, 'psr/log');
            }

            return new FakeChatLoggerTransport($this->logger);
        }

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

    public function create(Dsn $dsn): TransportInterface
    {
        trigger_deprecation('symfony/oh-my-smtp-mailer', '6.2', 'The "%s" class is deprecated, use "%s" instead.', self::class, MailPaceTransportFactory::class);

        $scheme = $dsn->getScheme();

        if ('ohmysmtp+api' === $scheme) {
            $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
            $port = $dsn->getPort();

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

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

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

    protected function getSupportedSchemes(): array
    {
        
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);
    }

    protected function getSupportedSchemes(): array
    {
        return [self::TRANSPORT_SCHEME];
    }
}
$scheme = $dsn->getScheme();

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

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

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

    protected function getSupportedSchemes(): array
    {
        return ['sendinblue'];
    }
}
public function create(Dsn $dsn): RingCentralTransport
    {
        $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 RingCentralTransport($apiKey$from$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }

    protected function getSupportedSchemes(): array
    {
        return [self::TRANSPORT_SCHEME];
    }
}
Home | Imprint | This part of the site doesn't use cookies.