public static function getAccessEntitiesForUser($user)
    {
        $entities = [];
        // If the user isnt registered, there is no need to do this anymore.
        if ($user->isRegistered()) {
            $ingids = [];
            $app = Facade::getFacadeApplication();
            /** @var $database \Concrete\Core\Database\Connection\Connection */
            $database = $app->make('database')->connection();

            // First look for any combos that this group would specifically be in.
            // We check if the combos contain any of the groups this user is in.
            // That way if there aren't any we can just skip it.
            foreach ($user->getUserGroups() as $key => $val) {
                $ingids[] = $key;
            }
            $instr = implode(',', $ingids);

            $peIDs = $database->fetchAll(
                'select distinct pae.peID from PermissionAccessEntities pae
                inner join PermissionAccessEntityTypes paet on pae.petID = paet.petID
                inner join PermissionAccessEntityGroups paeg on pae.peID = paeg.peID
                where petHandle = \'group_combination\' 
                and paeg.gID in (' . $instr . ')'
            );
            // Now for each one we check to see if it applies here.
            foreach ($peIDs as $peID) {
                $r = $database->fetchAssoc(
                    'select count(gID) as peGroups, 
                    (select count(UserGroups.gID) from UserGroups where uID = ? 
                      and gID in 
                      (select gID from PermissionAccessEntityGroups where peID = ?))
                     as uGroups from PermissionAccessEntityGroups where peID = ?',
                    [$user->getUserID(), $peID['peID'], $peID['peID']]
                );
                if ($r['peGroups'] == $r['uGroups'] && $r['peGroups'] > 1) {
                    $entity = Entity::getByID($peID['peID']);
                    if (is_object($entity)) {
                        $entities[] = $entity;
                    }
                }
            }
        }

        return $entities;
    }