src/Security/Group.php
public function inGroups($groups, $requireAll = false)
    {
        $ancestorIDs = $this->collateAncestorIDs();
        $candidateIDs = [];
        foreach ($groups as $group) {
            $groupID = $this->identifierToGroupID($group);
            if ($groupID) {
                $candidateIDs[] = $groupID;
            } elseif ($requireAll) {
                return false;
            }
        }
        if (empty($candidateIDs)) {
            return false;
        }
        $matches = array_intersect($candidateIDs, $ancestorIDs);
        if ($requireAll) {
            return count($candidateIDs) === count($matches);
        }
        return !empty($matches);
    }
public function inGroups($groups, $requireAll = false)
    {
        $ancestorIDs = $this->collateAncestorIDs();
        $candidateIDs = [];
        foreach ($groups as $group) {
            $groupID = $this->identifierToGroupID($group);
            if ($groupID) {
                $candidateIDs[] = $groupID;
            } elseif ($requireAll) {
                return false;
            }
        }
        if (empty($candidateIDs)) {
            return false;
        }
        $matches = array_intersect($candidateIDs, $ancestorIDs);
        if ($requireAll) {
            return count($candidateIDs) === count($matches);
        }
        return !empty($matches);
    }
public function inGroups ( $ groups , $ requireAll = false ) { $ ancestorIDs = $ this -> collateAncestorIDs ( ) ; $ candidateIDs = [ ] ; foreach ( $ groups as $ group ) { $ groupID = $ this -> identifierToGroupID ( $ group ) ; if ( $ groupID ) { $ candidateIDs [ ] = $ groupID ; } elseif ( $ requireAll ) { return false ; } } if ( empty ( $ candidateIDs ) ) { return false ; } $ matches = array_intersect ( $ candidateIDs , $ ancestorIDs ) ; if ( $ requireAll ) { return count ( $ candidateIDs ) === count ( $ matches ) ; } return ! empty ( $ matches ) ; }
Check if the group is a child of the given groups or any parent groups

@param (string|int|Group)[] $groups
@param bool $requireAll set to TRUE if must be in ALL groups, or FALSE if must be in ANY
@return bool Returns TRUE if the Group is a child of any of the given groups, otherwise FALSE
Check if the group is a child of the given groups or any parent groups