protected function getGroups() {
    $types = [];
    /** @var \Drupal\group\Entity\GroupType $group_type */
    foreach (GroupType::loadMultiple() as $group_type) {
      // We can only select group types that have the 'join group'
      // permission enabled.
      if (in_array('join group', $group_type->getOutsiderRole()->getPermissions())) {
        $types[] = $group_type;
      }
    }
    return $types;
  }
protected function getGroups() {
    $types = [];
    /** @var \Drupal\group\Entity\GroupType $group_type */
    foreach (GroupType::loadMultiple() as $group_type) {
      // We can only select group types that have the 'join group'
      // permission enabled.
      if (in_array('join group', $group_type->getOutsiderRole()->getPermissions())) {
        $types[] = $group_type;
      }
    }
    return $types;
  }
protected function getGroups ( ) { $ types = [ ] ; /** @var \Drupal\group\Entity\GroupType $group_type */ foreach ( GroupType :: loadMultiple ( ) as $ group_type ) { // We can only select group types that have the 'join group' // permission enabled. if ( in_array ( 'join group' , $ group_type -> getOutsiderRole ( ) -> getPermissions ( ) ) ) { $ types [ ] = $ group_type ; } } return $ types ; }
Function that returns all groups that outsider can become a member of.

@return array
Joinable groups.
Function that returns all groups that outsider can become a member of .