src/Tenant/Service/TenantService.php
public function getContext(): string
    {
        $tenant = $this->parameterService->get('ds_tenant.tenant.default');
        $request = $this->requestStack->getCurrentRequest();

        if ($request->request->has('tenant') && $request->request->get('tenant')) {
            $tenant = $request->request->get('tenant');
        }

        if ($request->query->has('tenant') && $request->query->get('tenant')) {
            $tenant = $request->query->get('tenant');
        }

        $token = $this->tokenStorage->getToken();

        if ($token) {
            $user = $token->getUser();

            if ($user instanceof User) {
                $tenant = $user->getTenant();
            }
        }

        return $tenant;
    }
public function getContext(): string
    {
        $tenant = $this->parameterService->get('ds_tenant.tenant.default');
        $request = $this->requestStack->getCurrentRequest();

        if ($request->request->has('tenant') && $request->request->get('tenant')) {
            $tenant = $request->request->get('tenant');
        }

        if ($request->query->has('tenant') && $request->query->get('tenant')) {
            $tenant = $request->query->get('tenant');
        }

        $token = $this->tokenStorage->getToken();

        if ($token) {
            $user = $token->getUser();

            if ($user instanceof User) {
                $tenant = $user->getTenant();
            }
        }

        return $tenant;
    }
Get the contextual tenant

@return string