Grants view access to group members for groupable entities.

@param GroupableInterface $groupable The groubale subject.
@param TokenInterface     $token     The user token.

@return bool
549985
public function canView(GroupableInterface $groupable, TokenInterface $token): bool
    {
        $user = $token->getUser();

        // Expirable entities can only be viewed by editors if expired.
        if ($groupable instanceof ExpirableInterface
            && $groupable->isExpired()) {
            $required_role = 'GROUP_ROLE_EDITOR';

        // Active entities can only be viewed by editors if not active.
        } elseif ($groupable instanceof ActiveInterface
            && !$groupable->isActive()) {
            $required_role = 'GROUP_ROLE_EDITOR';

        // Entity can be viewed by group users.
        } else {
            $required_role = 'GROUP_ROLE_USER';
        }

        // Iterate over groups and check access.
        foreach ($groupable->getGroups() as $group) {
            if ($this->decision_manager->decide($token, [$required_role], $group)) {
                return true;
            }
        }

        return false;
    }
1011669
public function addGroup(GroupInterface $group)
    {
        if (!$this->hasGroup($group)) {
            $this->groups->set($group->getName(), $group);
            $group->addUser($this);
        }

        return $this;
    }
1198008
public function clearNonce(TokenInterface $token)
    {
        if (true === $this->supports($token) && null !== $token->getNonce()) {
            $this->removeNonce($token->getNonce());
        }
    }
1069295
protected function userIsAllowed(TokenInterface $token)
    {
        /** @var \Symfony\Component\Security\Core\Role\RoleInterface $role */
        foreach ($this->hierarchy->getReachableRoles($token->getRoles()) as $role) {
            if ($role->getRole() === self::ROLE_ADMIN_MENU_ITEM) {
                return true;
            }
        }
        return false;
    }
797473
public function addGroup(GroupInterface $group)
    {
        if (Credentials::check()) {
            RevisionRepository::create([
                'revisionable_type' => get_class($this),
                'revisionable_id'   => $this->getKey(),
                'key'               => 'added_group',
                'old_value'         => null,
                'new_value'         => $group->getName(),
                'user_id'           => Credentials::getUser()->id,
            ]);
        }

        return parent::addGroup($group);
    }
1311073
public function userHasGroup($groupName, DeterminableUserInterface $user)
    {
        $userHasGroup = false;
        if (true === in_array($groupName, $user->getGroups())) {
            $userHasGroup = true;
        }
        return $userHasGroup;
    }
113785
protected function refreshUser(TokenInterface $token)
    {
        $user = $token->getUser();

        if (!$user instanceof UserInterface) {
            return;
        }

        $refreshedUser = $this->userProvider->refreshUser($user);
        $token->setUser($refreshedUser);

        return $token;
    }
1325487
public function getJoinedGroupList($limit, $offset, $groupType = null, $responseFilter = null)
    {
        $request = new GetJoinedGroupListRequest($this->identifier, $limit, $offset, $groupType, $responseFilter);
        $response = new GetJoinedGroupListResponse();
        return $this->client->sendRequest($request, $response);
    }
291164
protected function handle(Groupable $group, $field, $value, $name) : Groupable
  {
    return $group->assign($group->model()::where($field, 'like', '%' . $value . '%')->get() ?? new Collection);
  }
1309787
protected function setUpTokenValue(TokenInterface $token): int
    {
        list($tokenValue, $tokenType, $tokenExpiresIn) =
            $this->getIntegration()->generateTokenValues($token);
        $token->setValue($tokenValue)->setType($tokenType);

        return $tokenExpiresIn;
    }
389589
public function getGroupMember($groupId, $memberId)
	{
		return $this->sendRequest(
			$this->createRequest('GET', sprintf('groups/%d/members/%d', $groupId, $memberId))
		);
	}
61678
private function refreshUser(TokenInterface $token)
    {
        $user = $token->getUser();
        if (!$user instanceof UserInterface) {
            return $token;
        }

        if (null !== $this->logger) {
            $this->logger->debug(sprintf('Reloading user from user provider.'));
        }

        foreach ($this->userProviders as $provider) {
            try {
                $refreshedUser = $provider->refreshUser($user);
                $token->setUser($refreshedUser);

                if (null !== $this->logger) {
                    $this->logger->debug(sprintf('Username "%s" was reloaded from user provider.', $refreshedUser->getUsername()));
                }

                return $token;
            } catch (UnsupportedUserException $unsupported) {
                // let's try the next user provider
            } catch (UsernameNotFoundException $notFound) {
                if (null !== $this->logger) {
                    $this->logger->warning(sprintf('Username "%s" could not be found.', $notFound->getUsername()));
                }

                return;
            }
        }

        throw new \RuntimeException(sprintf('There is no user provider for user "%s".', get_class($user)));
    }
267006
public function hasGroup(GroupInterface $group): bool
    {
        foreach ($this->groups as $my_group) {
            if ($group->isEqualTo($my_group)) {
                return true;
            }
        }

        return false;
    }
1280001
public static function removeGroupContent(NodeInterface $node, Group $group) {
    // Try to load group content from entity.
    if ($group_contents = GroupContent::loadByEntity($node)) {
      /* @var @param \Drupal\group\Entity\GroupContent $group_content */
      foreach ($group_contents as $group_content) {
        if ($group->id() === $group_content->getGroup()->id()) {
          $group_content->delete();
        }
      }
    }
  }
69414
public function renderGroupWith($groupName, callable $renderer)
    {
        $this->parent->renderGroupWith($this->groupName($groupName), $renderer);

        return $this;
    }
649527
private function groupableVision(Groupable $group, $where, $value, $name, $querymap = null) : Groupable
  {
    if (strpos($where, '__') !== false) {
      $querymap = explode('__', $where)[1];
      $field = explode('__', $where)[0];
    }

    if (isset(HttpFoundation::$routeModelBinding['groupable'][$querymap])) {
      return (new HttpFoundation::$routeModelBinding['groupable'][$querymap])->persist($group, $field, $value, $name);
    }

    return $group;
  }
1294453
public function setGroupable($groupable = true)
    {
        foreach ($this->results as $name) {
            $this->columns->offsetGet($name)->setGroupable($groupable);
        }

        return $this;
    }