getHub example

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

        $hubId = $dsn->getHost();
        $topic = $dsn->getOption('topic');

        try {
            $hub = $this->registry->getHub($hubId);
        } catch (InvalidArgumentException) {
            throw new IncompleteDsnException(sprintf('Hub "%s" not found. Did you mean one of: "%s"?', $hubIdimplode('", "', array_keys($this->registry->all()))));
        }

        return new MercureTransport($hub$hubId$topic);
    }

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