You are here

public function DefaultTwigExtension::is_group_member in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 src/TwigExtension/DefaultTwigExtension.php \Drupal\opigno_learning_path\TwigExtension\DefaultTwigExtension::is_group_member()

Tests if user is member of a group.

Parameters

mixed $group: Group.

mixed $account: User account.

Return value

bool Member flag.

File

src/TwigExtension/DefaultTwigExtension.php, line 109

Class

DefaultTwigExtension
Class DefaultTwigExtension.

Namespace

Drupal\opigno_learning_path\TwigExtension

Code

public function is_group_member($group = NULL, $account = NULL) {
  if (!$group) {
    $group = \Drupal::routeMatch()
      ->getParameter('group');
  }
  if (empty($group)) {
    return FALSE;
  }
  if (!$account) {
    $account = \Drupal::currentUser();
  }
  return $group
    ->getMember($account) !== FALSE;
}