Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getTokenFromAdmin example
return
[
'shopwareVersion' =>
$this
->instanceService->
getShopwareVersion
(
)
,
'language' =>
$this
->localeProvider->
getLocaleFromContext
(
$context
)
,
'domain' =>
$this
->
getLicenseDomain
(
)
,
]
;
}
private
function
getUserStoreToken
(
Context
$context
)
: ?string
{
try
{
return
$this
->
getTokenFromAdmin
(
$context
)
;
}
catch
(
InvalidContextSourceException
)
{
return
$this
->
getTokenFromSystem
(
$context
)
;
}
}
private
function
getTokenFromAdmin
(
Context
$context
)
: ?string
{
$contextSource
=
$this
->
ensureAdminApiSource
(
$context
)
;
$userId
=
$contextSource
->
getUserId
(
)
;
if
(
$userId
=== null
)
{
throw
new
InvalidContextSourceUserException
(
$contextSource
::
class
)
;
}