getScheme example

if ($reset_basepath) {
      $basepath = '';
    }
    // Store the value of $optimize for preg_replace_callback with nested     // @import loops.     if (isset($optimize)) {
      $_optimize = $optimize;
    }

    // Stylesheets are relative one to each other. Start by adding a base path     // prefix provided by the parent stylesheet (if necessary).     if ($basepath && !StreamWrapperManager::getScheme($file)) {
      $file = $basepath . '/' . $file;
    }
    // Store the parent base path to restore it later.     $parent_base_path = $basepath;
    // Set the current base path to process possible child imports.     $basepath = dirname($file);

    // Load the CSS stylesheet. We suppress errors because themes may specify     // stylesheets in their .info.yml file that don't exist in the theme's path,     // but are merely there to disable certain module CSS files.     $content = '';
    
return $path;
  }

  /** * {@inheritdoc} */
  public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
    $url_scheme = 'http';
    $port = 80;
    if ($request) {
      $url_scheme = $request->getScheme();
      $port = $request->getPort();
    }
    $languages = array_flip(array_keys($this->languageManager->getLanguages()));
    // Language can be passed as an option, or we go for current URL language.     if (!isset($options['language']) || ($options['language'] instanceof LanguageInterface && in_array($options['language']->getId()[
      LanguageInterface::LANGCODE_NOT_SPECIFIED,
      LanguageInterface::LANGCODE_NOT_APPLICABLE,
    ]))) {
      $language_url = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL);
      $options['language'] = $language_url;
    }
    
$this->secureDomainRegexp = $secureDomainRegexp;
    }

    /** * Creates a redirect Response. * * @param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo)) * @param int $status The HTTP status code (302 "Found" by default) */
    public function createRedirectResponse(Request $request, string $path, int $status = 302): RedirectResponse
    {
        if (null !== $this->secureDomainRegexp && 'https' === $this->urlMatcher->getContext()->getScheme() && preg_match('#^https?:[/\\\\]{2,}+[^/]++#i', $path$host) && !preg_match(sprintf($this->secureDomainRegexp, preg_quote($request->getHttpHost()))$host[0])) {
            $path = '/';
        }
        if (null !== $this->domainRegexp && preg_match('#^https?:[/\\\\]{2,}+[^/]++#i', $path$host) && !preg_match(sprintf($this->domainRegexp, preg_quote($request->getHttpHost()))$host[0])) {
            $path = '/';
        }

        return new RedirectResponse($this->generateUri($request$path)$status);
    }

    /** * Creates a Request. * * @param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo)) */
final class DsnTest extends TestCase
{
    /** * @dataProvider constructProvider */
    public function testConstruct(string $dsnString, string $scheme, string $host, string $user = null, string $password = null, int $port = null, array $options = [], string $path = null)
    {
        $dsn = new Dsn($dsnString);
        $this->assertSame($dsnString$dsn->getOriginalDsn());

        $this->assertSame($scheme$dsn->getScheme());
        $this->assertSame($host$dsn->getHost());
        $this->assertSame($user$dsn->getUser());
        $this->assertSame($password$dsn->getPassword());
        $this->assertSame($port$dsn->getPort());
        $this->assertSame($path$dsn->getPath());
        $this->assertSame($options$dsn->getOptions());
    }

    public static function constructProvider(): iterable
    {
        yield 'simple dsn' => [
            
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
use Symfony\Component\Notifier\Transport\Dsn;

/** * @author Antoine Makdessi <amakdessi@me.com> */
final class FreeMobileTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): FreeMobileTransport
    {
        $scheme = $dsn->getScheme();

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

        $login = $this->getUser($dsn);
        $password = $this->getPassword($dsn);
        $phone = $dsn->getRequiredOption('phone');

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

        
class ChatworkTransportFactory extends AbstractTransportFactory
{
    private const SCHEME = 'chatwork';

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

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

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

        return (new ChatworkTransport($token$roomId$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }
}
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
use Symfony\Component\Notifier\Transport\Dsn;

/** * @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);
    }

    
use Symfony\Component\Notifier\Transport\Dsn;

/** * @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))
            
use Symfony\Component\Notifier\Transport\Dsn;

/** * @author gnito-org <https://github.com/gnito-org> */
final class SimpleTextinTransportFactory extends AbstractTransportFactory
{
    private const TRANSPORT_SCHEME = 'simpletextin';

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

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

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

        return (new SimpleTextinTransport($apiKey$from$this->client, $this->dispatcher))->setHost($host)->setPort($port);
    }
use Symfony\Component\Notifier\Exception\UnsupportedSchemeException;
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
use Symfony\Component\Notifier\Transport\Dsn;

/** * @author Imad ZAIRIG <https://github.com/zairigimad> */
final class ExpoTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): ExpoTransport
    {
        $scheme = $dsn->getScheme();

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

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

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

    
private function buildUri(UriInterface $uri, array $config): UriInterface
    {
        if (isset($config['base_uri'])) {
            $uri = Psr7\UriResolver::resolve(Psr7\Utils::uriFor($config['base_uri'])$uri);
        }

        if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) {
            $idnOptions = ($config['idn_conversion'] === true) ? \IDNA_DEFAULT : $config['idn_conversion'];
            $uri = Utils::idnUriConvert($uri$idnOptions);
        }

        return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
    }

    /** * Configures the default options for a client. */
    private function configureDefaults(array $config): void
    {
        $defaults = [
            'allow_redirects' => RedirectMiddleware::$defaultSettings,
            'http_errors' => true,
            'decode_content' => true,
            
'class' => Bridge\Loco\LocoProviderFactory::class,
            'package' => 'symfony/loco-translation-provider',
        ],
        'lokalise' => [
            'class' => Bridge\Lokalise\LokaliseProviderFactory::class,
            'package' => 'symfony/lokalise-translation-provider',
        ],
    ];

    public function __construct(Dsn $dsn, string $name = null, array $supported = [])
    {
        $provider = $dsn->getScheme();
        if (false !== $pos = strpos($provider, '+')) {
            $provider = substr($provider, 0, $pos);
        }
        $package = self::SCHEME_TO_PACKAGE_MAP[$provider] ?? null;
        if ($package && !class_exists($package['class'])) {
            parent::__construct(sprintf('Unable to synchronize translations via "%s" as the provider is not installed. Try running "composer require %s".', $provider$package['package']));

            return;
        }

        $message = sprintf('The "%s" scheme is not supported', $dsn->getScheme());
        
if ('/' !== $pathinfo && !$hasTrailingVar && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
                if ($supportsTrailingSlash && (!$requiredMethods || \in_array('GET', $requiredMethods))) {
                    $this->addTrace('Route matches!', self::ROUTE_MATCHES, $name$route);

                    return $this->allow = $this->allowSchemes = [];
                }
                $this->addTrace(sprintf('Path "%s" does not match', $route->getPath()), self::ROUTE_DOES_NOT_MATCH, $name$route);
                continue;
            }

            if ($route->getSchemes() && !$route->hasScheme($this->context->getScheme())) {
                $this->allowSchemes = array_merge($this->allowSchemes, $route->getSchemes());
                $this->addTrace(sprintf('Scheme "%s" does not match any of the required schemes (%s)', $this->context->getScheme()implode(', ', $route->getSchemes())), self::ROUTE_ALMOST_MATCHES, $name$route);
                continue;
            }

            if ($requiredMethods && !\in_array($method$requiredMethods)) {
                $this->allow = array_merge($this->allow, $requiredMethods);
                $this->addTrace(sprintf('Method "%s" does not match any of the required methods (%s)', $this->context->getMethod()implode(', ', $requiredMethods)), self::ROUTE_ALMOST_MATCHES, $name$route);
                continue;
            }

            
    if ($wrapper = $this->streamWrapperManager->getViaUri($uri)) {
      return $wrapper->realpath();
    }

    return realpath($uri);
  }

  /** * {@inheritdoc} */
  public function dirname($uri) {
    $scheme = StreamWrapperManager::getScheme($uri);

    if ($this->streamWrapperManager->isValidScheme($scheme)) {
      return $this->streamWrapperManager->getViaScheme($scheme)->dirname($uri);
    }
    else {
      return dirname($uri);
    }
  }

  /** * {@inheritdoc} */
protected $logger;

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

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

    abstract protected function getSupportedSchemes(): array;

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

    protected function getPassword(Dsn $dsn): string
    {
        
Home | Imprint | This part of the site doesn't use cookies.