Craft\NeoService::getGroupsByFieldId PHP Method

getGroupsByFieldId() public method

Returns a list of groups associated with a field.
public getGroupsByFieldId ( $fieldId, string | null $indexBy = null ) : array
$fieldId
$indexBy string | null
return array
    public function getGroupsByFieldId($fieldId, $indexBy = null)
    {
        if (empty($this->_fetchedAllGroupsForFieldId[$fieldId])) {
            $this->_groupsByFieldId[$fieldId] = [];
            $results = $this->_createGroupQuery()->where('fieldId = :fieldId', [':fieldId' => $fieldId])->queryAll();
            foreach ($results as $result) {
                $group = new Neo_GroupModel($result);
                $this->_groupsById[$group->id] = $group;
                $this->_groupsByFieldId[$fieldId][] = $group;
            }
            $this->_fetchedAllGroupsForFieldId[$fieldId] = true;
        }
        if ($indexBy) {
            return $this->_indexBy($this->_groupsByFieldId[$fieldId], $indexBy);
        }
        return $this->_groupsByFieldId[$fieldId];
    }