在群组中发送系统通知
@param string $content
@param array $members
@return BaseResponse
@throws Exception\TIMException
19344
public function sendSystemNotification($content, $members = [])
    {
        $request = new SendGroupSystemNotificationRequest($this->groupId);
        $request->setContent($content);
        $request->setToMembersAccount($members);
        $response = new BaseResponse();
        return $this->client->sendRequest($request, $response);
    }
936238
public static function create(array $tokens, $content) {
        if (empty($content) || !is_array($content)) return [];
        return empty($content[0]) ? SelectSingleResult::create($tokens, $content) : SelectAllResult::create($tokens, $content);
    }
1365217
public function sAdd($key, $member, ...$members) {
        return $this->send(array_merge(['sadd', $key], (array) $member, $members));
    }
740503
public static function create(array $tokens, $content) {
        HashMap::assert($tokens, 'tokens');
        $tableAlias = Table::alias($tokens);

        $attributeValueMap = array_map(function($token) use ($content, $tableAlias) {
            $key   = empty($token['alias']['name']) ? $token['base_expr'] : $token['alias']['name'];
            $value = $content[str_replace($tableAlias . '.', '', $token['base_expr'])];
            return [$key => $value];
        }, $tokens['SELECT']);

        return [ array_reduce($attributeValueMap, 'array_merge', []) ];
    }
431239
public function createCreateStructFromContent(Content $content)
    {
        $struct = new CreateStruct();
        $struct->name = $content->versionInfo->names;
        $struct->typeId = $content->versionInfo->contentInfo->contentTypeId;
        $struct->sectionId = $content->versionInfo->contentInfo->sectionId;
        $struct->ownerId = $content->versionInfo->contentInfo->ownerId;
        $struct->locations = array();
        $struct->alwaysAvailable = $content->versionInfo->contentInfo->alwaysAvailable;
        $struct->remoteId = md5(uniqid(get_class($this), true));
        $struct->initialLanguageId = $this->languageHandler->loadByLanguageCode($content->versionInfo->initialLanguageCode)->id;
        $struct->mainLanguageId = $this->languageHandler->loadByLanguageCode($content->versionInfo->contentInfo->mainLanguageCode)->id;
        $struct->modified = time();

        foreach ($content->fields as $field) {
            $newField = clone $field;
            $newField->id = null;
            $struct->fields[] = $newField;
        }

        return $struct;
    }
1340511
public function newToken(array $content = [], $expire = null)
    {
        $entity = $this->newEntity([
            'id' => $this->uniqId(),
            'content' => $content,
            'expire' => is_null($expire) ? Chronos::parse('+1 day') : Chronos::parse($expire),
        ]);

        $this->save($entity);

        return $entity->id;
    }
870022
public function setContent(string $content = null): ResponseContextAbstract
    {
        if (is_null($content)) {
            return $this;
        }

        $this->assertIsValid($content);

        $this->content = $content;

        return $this;
    }
601619
public static function add_group_members($members) {
        global $CFG, $DB;
        require_once("$CFG->dirroot/group/lib.php");

        $params = self::validate_parameters(self::add_group_members_parameters(), array('members'=>$members));

        $transaction = $DB->start_delegated_transaction();
        foreach ($params['members'] as $member) {
            // validate params
            $groupid = $member['groupid'];
            $userid = $member['userid'];

            $group = groups_get_group($groupid, '*', MUST_EXIST);
            $user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0, 'mnethostid'=>$CFG->mnet_localhost_id), '*', MUST_EXIST);

            // now security checks
            $context = context_course::instance($group->courseid, IGNORE_MISSING);
            try {
                self::validate_context($context);
            } catch (Exception $e) {
                $exceptionparam = new stdClass();
                $exceptionparam->message = $e->getMessage();
                $exceptionparam->courseid = $group->courseid;
                throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
            }
            require_capability('moodle/course:managegroups', $context);

            // now make sure user is enrolled in course - this is mandatory requirement,
            // unfortunately this is slow
            if (!is_enrolled($context, $userid)) {
                throw new invalid_parameter_exception('Only enrolled users may be members of groups');
            }

            groups_add_member($group, $user);
        }

        $transaction->allow_commit();
    }
1301855
final public function whereIn(string $memberExpression, array $values)
    {
        return $this->where($memberExpression, ConditionOperator::IN, $values);
    }
734671
public function create($content, $code = 200, $headers = [], $charset = null)
    {
        return $this->serializer->serialize(
            new Response($content, $code, $headers, $charset),
            'json'
        );
    }
969678
public function write($content) {
        if (is_string($content) || is_numeric($content)) {
            $this->writeString($content);
        } elseif (is_bool($content)) {
            $this->writeString($content ? "TRUE" : "FALSE");
        } elseif (is_array($content)) {
            $this->writeString("Array(" . count($content) . ")");
        } elseif (is_object($content) && method_exists($content, "__toString")) {
            $this->writeString(strval($content));
        } elseif (is_null($content)) {
            $this->writeString("NULL");
        } elseif (is_resource($content)) {
            $this->writeString("Resource###");
        } else {
            throw new InvalidContentException();
        }
    }
601568
protected function setContent($content)
    {
        $this->content = (string) $content;

        if (empty($this->content)) {
            throw new \Exception('Header content is empty !');
        }

        return $this;
    }
813475
public function write($cacheFile, $content)
    {
        // 添加写入时间
        $content = $_SERVER['REQUEST_TIME'] . $content;
        if (!$this->mc->set($cacheFile, $content, 0)) {
            throw new Exception('sae mc write error:' . $cacheFile);
        } else {
            $this->contents[$cacheFile] = $content;
            return true;
        }
    }
1008343
public function zRem($key, $member, ...$members) {
        return $this->send(array_merge(['zrem', $key], (array) $member, $members));
    }
1095462
public function timelineMember($member, $token = null, $number = null)
    {
        $params = array();

        // handle token parameter
        if (!is_null($token)) {
            $params['token'] = $token;
        }

        // handle number parameter
        if (!is_null($number)) {
            if (!ctype_digit((string)$number) || (0 === $number) || (100 < $number)) {
                throw new \InvalidArgumentException('Invalid number parameter');
            }
            $params['number'] = $number;
        }

        return $this->query('timeline/member/' . $member . '.json', $params);
    }
916960
protected function buildMessage(string $content, array $records): Swift_Message
    {
        $message = null;
        if ($this->messageTemplate instanceof Swift_Message) {
            $message = clone $this->messageTemplate;
            $message->generateId();
        } elseif (is_callable($this->messageTemplate)) {
            $message = call_user_func($this->messageTemplate, $content, $records);
        }

        if (!$message instanceof Swift_Message) {
            throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it');
        }

        if ($records) {
            $subjectFormatter = $this->getSubjectFormatter($message->getSubject());
            $message->setSubject($subjectFormatter->format($this->getHighestRecord($records)));
        }

        $mime = 'text/plain';
        if ($this->isHtmlBody($content)) {
            $mime = 'text/html';
        }

        $message->setBody($content, $mime);
        if (version_compare(Swift::VERSION, '6.0.0', '>=')) {
            $message->setDate(new \DateTimeImmutable());
        } else {
            $message->setDate(time());
        }

        return $message;
    }
915753
protected function stringOrCallback($content)
    {
        if( is_scalar($content) )
        {
            return $content;
        }
        elseif( is_callable($content) )
        {
            return Buffering\Callback::do($content);
        }

        throw new Exception\InvalidArgumentException('1.($content) parameter must be [scalar] or [callable] type!');
    }