获取topic Members
@param $topic
@return array
198369
public function th_getSubMembers($topic)
    {
        if (array_key_exists($topic, $this->subArr) && !empty($this->subArr[$topic])) {
            return $this->subArr[$topic]->toArray();
        } else {
            return [];
        }
    }
617610
public function members($group, $fields = [])
    {
        $group = $this->find($group);

        if (is_array($group) && array_key_exists('member', $group)) {
            $members = [];

            foreach ($group['member'] as $member) {
                $members[] = $this->adldap->search()
                    ->setDn($member)
                    ->select($fields)
                    ->where('objectClass', '=', 'user')
                    ->where('objectClass', '=', 'person')
                    ->first();
            }

            return $members;
        }

        return false;
    }
270887
public function requestRun($topic)
    {
        if (!array_key_exists($topic, $this->fuses)) {
            $this->fuses[$topic] = ['success' => 0, 'fail' => 0, 'time' => getTickTime(), 'state' => self::OPEN, 'stoptime' => 0, 'trycount' => 0, 'trysuccess' => 0];
            return self::OPEN;
        }
        $fuse = &$this->fuses[$topic];
        switch ($fuse['state']) {
            case self::CLOSE://断路状态
                if (getTickTime() - $fuse['stoptime'] >= $this->TRYTIME) {//1秒后尝试打开
                    $fuse['state'] = self::TRY;
                    $fuse['trycount'] = 0;
                    $fuse['trysuccess'] = 0;
                    return self::OPEN;
                } else {
                    return self::CLOSE;
                }
                break;
            case self::TRY://尝试状态
                if ($fuse['trysuccess'] >= $this->TRYMAX) {//全部都尝试成功，那么可以放开流量试试
                    $fuse['state'] = self::OPEN;
                    $fuse['trysuccess'] = 0;
                    return self::OPEN;
                }
                if ($fuse['trycount'] < $this->TRYMAX) {//放开1次请求看看情况
                    $fuse['trycount']++;
                    return self::OPEN;
                } else {
                    return self::CLOSE;
                }
                break;
            case self::OPEN://正常状态
                $total = ($fuse['success'] + $fuse['fail']);
                if ($total == 0) return self::OPEN;
                $threshold = $fuse['fail'] / ($fuse['success'] + $fuse['fail']);
                if ($threshold > $this->THRESHOLD) {
                    $fuse['state'] = self::CLOSE;
                    $fuse['stoptime'] = getTickTime();
                    return self::CLOSE;
                } else {
                    return self::OPEN;
                }
                break;
        }
    }
379423
public function getAllPeriodicTimers(TopicInterface $topic, $name)
    {
        if (!$this->isPeriodicTimerActive($topic, $name)) {
            return false;
        }

        $namespace = $this->getTopicNamespace($topic);

        return $this->registry[$namespace][$name];
    }
464410
public function publishMessage(string $topicName, string $message){
        if(!$topicName || !$message){
            return $this->error('参数有误');
        }
        $topic = $this->client->getTopicRef($topicName);
        $request = new PublishMessageRequest($message);
        try{
            $topic->publishMessage($request);
            return $this->success('发布消息成功');
        }catch(MnsException $exception){
            return $this->parseException($exception, '发布消息');
        }
    }
915018
public function do_delete($topic)
    {
        $redis = is_object($this->_redis) ? $this->_redis : $this->_getRedis();
        foreach ($this->_priorities as $priority) {
            $redis->delete($this->_prefix . $topic . ':' . $priority);
        }
    }
1260244
protected function getPaginatedMembers()
    {
        $members = [];

        $keys = array_keys($this->attributes);

        // We need to filter out the model attributes so
        // we only retrieve the member range.
        $attributes = array_values(array_filter($keys, function ($key) {
            return strpos($key,'member;range') !== false;
        }));

        // We'll grab the member range key so we can run a
        // regex on it to determine the range.
        $key = reset($attributes);

        preg_match_all(
            '/member;range\=([0-9]{1,4})-([0-9*]{1,4})/',
            $key,
            $matches
        );

        if ($key && count($matches) == 3) {
            // Retrieve the ending range number.
            $to = $matches[2][0];

            // Retrieve the current groups members from the
            // current range string (ex. 'member;0-50').
            $members = $this->getMembersFromAttribute($key);

            // If the query already included all member results (indicated
            // by the '*'), then we can return here. Otherwise we need
            // to continue on and retrieve the rest.
            if($to === '*') {
                return $members;
            }

            // Determine the amount of members we're requesting per query.
            $range = $to - $matches[1][0];

            // Set our starting range to our last end range plus one.
            $from = $to + 1;

            // We'll determine the new end range by adding the
            // total range to our new starting range.
            $to = $from + $range;

            // We'll need to query for the current model again but with
            // a new range to retrieve the other members.
            /** @var Group $group */
            $group = $this->query->newInstance()->findByDn(
                $this->getDn(),
                [$this->query->getSchema()->memberRange($from, $to)]
            );

            // Finally, we'll merge our current members
            // with the newly returned members.
            $members = array_merge(
                $members,
                $group->getMembers()->toArray()
            );
        }

        return $members;
    }
1192320
public function commitTimeOutOrFaile($topic)
    {
        $fuse = &$this->fuses[$topic];
        $this->cleanData($fuse);
        if ($fuse['state'] == self::CLOSE) {
            return;
        }
        $fuse['fail']++;
        //尝试状态下出现一次错误就直接close
        if ($fuse['state'] == self::TRY) {
            $fuse['trysuccess'] = 0;
            $fuse['state'] = self::CLOSE;
            $fuse['stoptime'] = getTickTime();
        }
    }
1337051
private function get_exported_discussion(stdClass $user) : array {
        $discussionexporter = $this->exporterfactory->get_discussion_exporter(
            $user,
            $this->forum,
            $this->discussion,
            $this->get_groups_available_in_forum()
        );

        return (array) $discussionexporter->export($this->renderer);
    }
1059097
private function mapTopic($topic)
    {
        if (array_key_exists($topic, self::TOPIC_TO_ID_ENUM)) {
            $result = self::TOPIC_TO_ID_ENUM[$topic];
            $this->logger->debug(sprintf('Topic "%s" has been mapped to "%s".', $topic, $result));
        } else {
            $result = $topic;
            $this->logger->debug(sprintf('Topic "%s" does not exist in enum.', $topic));
        }

        return $result;
    }
365889
public function transform(Member $member)
    {
        return [
            'createdAt' => $member->created_at->toW3cString(),
            'memberCategoryId' => $member->member_category_id,
            'memberCategoryName' => !empty($member->member_category) ? $member->member_category->name : null,
            'memberName' => $member->user->name,
            'id' => $member->id,
            'role' => $member->role,
            'status' => $member->status,
            'preference' => $member->preference,
            'updatedAt' => $member->updated_at->toW3cString(),
            'userId' => $member->user_id,
        ];
    }
1206015
public function getByStatus($status)
    {
        $components = [];

        foreach ($this->all() as $name => $component) {
            if ($component->isStatus($status)) {
                $components[$name] = $component;
            }
        }

        return $components;
    }
738398
final public static function membersByPredicate($predicate)
    {
        $members = array();

        foreach (static::members() as $key => $member) {
            if ($predicate($member)) {
                $members[$key] = $member;
            }
        }

        return $members;
    }
111630
public function getAsGroupedArray(): array
    {
        $result = array();

        foreach ($this->_groups as $groupName => $memberKeys) {
            $members = array();

            foreach ($memberKeys as $key) {
                $members[$key] = $this->getFieldAsArray($key);
            }

            $result[$groupName] = array(
                'group_name' => $groupName,
                'group_caption' => $this->_('group_' . $groupName),
                'fields' => $members
            );
        }

        return $result;
    }
191600
public function createTopic(string $topicName, $attributes=null) {
        if(!$topicName){
            return $this->error('参数有误');
        }
        $request = new CreateTopicRequest($topicName, $attributes);
        try{
            $this->client->createTopic($request);
            return $this->success('创建主题成功');
        }catch(MnsException $exception){
            return $this->parseException($exception, '创建主题');
        }
    }
1097882
public function sitesManagedByMember($member = null)
    {
        $member = $member ?: Member::currentUser();
        if (!$member) return array();

        $sites = Site::get();

        if (Permission::check('ADMIN')) {
            return $sites->column('ID');
        }

        $memberGroups = $member->Groups()->column('ID');
        $sites        = $sites->filter("EditorGroups.ID:ExactMatch", $memberGroups);

        return $sites->column('ID');
    }
1290858
public static function getCollectionTopics(Collection $collection) {
		$url = self::getTopicsUrl($collection);

		$response = Client::GET($url, self::getHeaders($collection));

		$body = self::getDataFromResponse($response);
		if (!property_exists($body, "topicIds")) {
			return null;
		}

		return $body->{"topicIds"};
	}