You are here

protected function OgSelection::getUserGroups in Organic groups 8

Return all the user's groups.

Return value

\Drupal\Core\Entity\ContentEntityInterface[] Array with the user's group, or an empty array if none found.

1 call to OgSelection::getUserGroups()
OgSelection::buildEntityQuery in src/Plugin/EntityReferenceSelection/OgSelection.php
Overrides ::buildEntityQuery.

File

src/Plugin/EntityReferenceSelection/OgSelection.php, line 126

Class

OgSelection
Provide default OG selection handler.

Namespace

Drupal\og\Plugin\EntityReferenceSelection

Code

protected function getUserGroups() {

  /** @var \Drupal\og\MembershipManagerInterface $membership_manager */
  $membership_manager = \Drupal::service('og.membership_manager');
  $other_groups = $membership_manager
    ->getUserGroups($this->currentUser
    ->id());
  return isset($other_groups[$this->configuration['target_type']]) ? $other_groups[$this->configuration['target_type']] : [];
}