获取分组的所有上级分组

@return GroupModel|GroupModel[]
@throws \Exception
189658
public function getParents()
    {
        if (!$this->parents) {
            $groups = wei()->group->getGroupsFromCache();

            $parents = wei()->groupModel()->beColl();
            $parents[] = $this;

            $group = $this;
            while ($group->parentId) {
                $group = $groups[$group->parentId];
                $parents[] = $group;
            }

            $this->parents = $parents;
        }

        return $this->parents;
    }
1263625
public function getGroups()
    {
        $data  = $this->getData();
        $groups = KObjectConfig::unbox($data->groups);

        if(empty($groups)) {
            $this->getSession()->set('user.groups', JAccess::getGroupsByUser($this->getId()));
        }

        return parent::getGroups();
    }
29158
public function getGroups()
	{
		if ( ! $this->userGroups)
		{
			$this->userGroups = $this->groups()->get();
		}

		return $this->userGroups;
	}
693916
public function orGroup()
    {
        $conditions = func_get_args();
        if (Collection::count($conditions) == 0) {
            throw new ErrorException('Missing arguments for orGroup() ');
        }
        //
        return $this->groupWhere($conditions[0], 'or', $conditions);
    }
152044
public function getGroups() {
		$data = $this->getData('/cgi-bin/groups/get', [
			'access_token' => $this->getAccessToken(),
		]);

		if(isset($data['groups'])) {
			foreach($data['groups'] as $_group) {
				$group = WechatUserGroup::findOne(['appid' => $this->app->appid, 'gid' => $_group['id']]);
				if(!$group) {
					$group = new WechatUserGroup;
					$group->appid = $this->app->appid;
					$group->gid = $_group['id'];
				}
				$group->name = $_group['name'];
				$group->count = $_group['count'];
				$group->save();
			}
		}

		return $this->errcode == 0;
	}
372601
public function getCustomerGroups()
    {
        $groups = [];

        /** @var GroupInterface $customerGroup */
        foreach ($this->customerGroupCollection->getItems() as $customerGroup) {
            $group               = [];
            $group['id']         = $customerGroup->getId();
            $group['name']       = $customerGroup->getCode();
            $group['is_default'] = intval($customerGroup->getId() == GroupInterface::NOT_LOGGED_IN_ID);

            $matchingTaxClasses =
                $this->taxCollection->getItemsByColumnValue('class_id', $customerGroup->getTaxClassId());

            if (count($matchingTaxClasses)) {
                $group['customer_tax_class_key'] = array_pop($matchingTaxClasses)->getClassName();
            }

            $groups[] = $group;
        }

        return $groups;
    }
105794
public function groupLinksGroupedBySource(){
        return $this->map(function(Link $linkObj){
                        return 
                            ['link' => $linkObj->getAbsoluteUrl(),
                             'source_link' => $linkObj->getParentUrl()];                                
                    })
                    ->unique('link')
                    ->groupBy('source_link');        
    }
1048514
public function getGroup()
    {
        if ($this->group === null) {
            $this->setGroup($this->groupRepository->getByClass($this));
        }
        return $this->group;
    }
285513
protected function getGroups()
	{
		$groups = array();
		$label = 0;

		$select = new HtmlSelect;

		// Try to inject the text object into the field
		try
		{
			$select->setText($this->getText());
		}
		catch (\RuntimeException $exception)
		{
			// A Text object was not set, ignore the error and try to continue processing
		}

		/** @var \SimpleXMLElement $element */
		foreach ($this->element->children() as $element)
		{
			switch ($element->getName())
			{
				// The element is an <option />
				case 'option':
					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Create a new option object based on the <option /> element.
					$tmp = $select->option(
						($element['value']) ? (string) $element['value'] : trim((string) $element),
						$this->getText()->alt(trim((string) $element), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)), 'value', 'text',
						((string) $element['disabled'] == 'true')
					);

					// Set some option attributes.
					$tmp->class = (string) $element['class'];

					// Set some JavaScript option attributes.
					$tmp->onclick = (string) $element['onclick'];

					// Add the option.
					$groups[$label][] = $tmp;
					break;

				// The element is a <group />
				case 'group':
					// Get the group label.
					if ($groupLabel = (string) $element['label'])
					{
						$label = $this->translateLabel ? $this->getText()->translate($groupLabel) : $groupLabel;
					}

					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Iterate through the children and build an array of options.
					/** @var \SimpleXMLElement $option */
					foreach ($element->children() as $option)
					{
						// Only add <option /> elements.
						if ($option->getName() != 'option')
						{
							continue;
						}

						// Create a new option object based on the <option /> element.
						$tmp = $select->option(
							($option['value']) ? (string) $option['value'] : $this->getText()->translate(trim((string) $option)),
							$this->getText()->translate(trim((string) $option)), 'value', 'text', ((string) $option['disabled'] == 'true')
						);

						// Set some option attributes.
						$tmp->class = (string) $option['class'];

						// Set some JavaScript option attributes.
						$tmp->onclick = (string) $option['onclick'];

						// Add the option.
						$groups[$label][] = $tmp;
					}

					if ($groupLabel)
					{
						$label = count($groups);
					}
					break;

				// Unknown element type.
				default:
					throw new \UnexpectedValueException(
						sprintf('Unsupported element %1$s in %2$s', $element->getName(), __CLASS__),
						500
					);
			}
		}

		reset($groups);

		return $groups;
	}
247930
public function getGroups()
    {
        $groups = [];

        foreach ($this->rootlineElements as $rootlineElement) {
            $rootlineElementGroups = $rootlineElement->getGroups();
            $groups = array_merge($groups, $rootlineElementGroups);
        }

        $groups = $this->cleanGroupArray($groups);

        return $groups;
    }
488213
public function groups()
    {
        $result = [];
        foreach ($this->_config['groups'] as $group) {
            $value = xcache_get($this->_config['prefix'] . $group);
            if (!$value) {
                $value = 1;
                xcache_set($this->_config['prefix'] . $group, $value, 0);
            }
            $result[] = $group . $value;
        }

        return $result;
    }
1166829
public function groups()
    {
        if ($this->groups === null) {
            $ident    = $this->ident();
            $metadata = $this->adminSecondaryMenu();

            $this->groups = [];
            if (isset($metadata[$ident]['groups'])) {
                $groups = $metadata[$ident]['groups'];

                if (is_array($groups)) {
                    $this->setGroups($groups);
                }
            }
        }

        return $this->groups;
    }
901004
public function getGroup()
    {
        $this->group || $this->group = wei()->group()->findOrInitById($this['groupId'], ['name' => '未分组']);

        return $this->group;
    }
440670
public function group()
    {
        if (func_num_args() > 0) {
            $types = func_get_args();
            $this->groupForRender = array();
            foreach ($types as $type) {
                $this->addToGrouping($type);
            }
        }

        return $this;
    }
1300931
public function getGroupList()
    {
        $result = $this->httpRaw(self::WECHAT_GROUP_GET_URL . 'access_token=' . $this->getAccessToken());
        return isset($result['groups']) ? $result['groups'] : false;
    }
405538
public function toArray(): array
    {
        $groups = [];

        foreach ($this->groups as $group) {
            $key = Key::sanitize($group['name']);

            $key = sprintf('%s_%s', $this->parentKey, $key);

            $group = [
                'field' => sprintf('field_%s', Key::hash($key)),
                'operator' => $group['operator'],
                'value' => $group['value'],
            ];

            $groups[] = $group;
        }

        return $groups;
    }
341821
public function getGroupList()
    {
        $result = $this->wechat->httpGet(self::WECHAT_GROUP_LIST_PREFIX, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['groups_detail'] : false;
    }