Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
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"?',
$hubId
,
implode
(
'", "',
array_keys
(
$this
->registry->
all
(
)
)
)
)
)
;
}
return
new
MercureTransport
(
$hub
,
$hubId
,
$topic
)
;
}
protected
function
getSupportedSchemes
(
)
: array
{
return
[
'mercure'
]
;
}
}