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);
} return $this->
fetchUserStoreToken(new Criteria([$userId]),
$context);
} private function getTokenFromSystem(Context
$context): ?string
{ $contextSource =
$context->
getSource();