src/ViewCombination/ViewCombination.php
public function getCombinations()
    {
        $user = $this->getUser();

        switch (true) {
            case ($user instanceof BackendUser):
                $mode = 'be';
                // Try to get the group(s)
                // there might be a NULL in there as BE admins have no groups and
                // user might have one but it is not mandatory.
                // I would prefer a default group for both, fe and be groups.
                $groups = $user->groups;
                // Special case in combinations, admins have the implicit group id -1.
                if ($user->admin) {
                    $groups[] = -1;
                }

                break;
            case ($user instanceof FrontendUser):
                $mode   = 'fe';
                $groups = $user->groups;
                // Special case in combinations, anonymous frontend users have the implicit group id -1.
                if (!$this->getUser()->id) {
                    $groups = [-1];
                }

                break;
            default:
                // Default handled as frontend anonymous.
                $mode   = 'fe';
                $groups = [-1];
        }

        $groups = array_filter($groups);

        if ($this->cache->contains($cacheKey = 'combinations_' . $mode . '_' . implode(',', $groups))) {
            return $this->cache->fetch($cacheKey);
        }

        $combinations = $this->builder->getCombinationsForUser($groups, $mode);

        $this->cache->save($cacheKey, $combinations);

        return $combinations;
    }
public function getCombinations()
    {
        $user = $this->getUser();

        switch (true) {
            case ($user instanceof BackendUser):
                $mode = 'be';
                // Try to get the group(s)
                // there might be a NULL in there as BE admins have no groups and
                // user might have one but it is not mandatory.
                // I would prefer a default group for both, fe and be groups.
                $groups = $user->groups;
                // Special case in combinations, admins have the implicit group id -1.
                if ($user->admin) {
                    $groups[] = -1;
                }

                break;
            case ($user instanceof FrontendUser):
                $mode   = 'fe';
                $groups = $user->groups;
                // Special case in combinations, anonymous frontend users have the implicit group id -1.
                if (!$this->getUser()->id) {
                    $groups = [-1];
                }

                break;
            default:
                // Default handled as frontend anonymous.
                $mode   = 'fe';
                $groups = [-1];
        }

        $groups = array_filter($groups);

        if ($this->cache->contains($cacheKey = 'combinations_' . $mode . '_' . implode(',', $groups))) {
            return $this->cache->fetch($cacheKey);
        }

        $combinations = $this->builder->getCombinationsForUser($groups, $mode);

        $this->cache->save($cacheKey, $combinations);

        return $combinations;
    }
Obtain the combinations for the current user.

@return array|null