/** * @param array $fields * @param array $attributes * @param array $rules * @param bool $throwException * * @return DynamicModel */ protected function checkParams(array $fields, array $attributes = [], array $rules = [], $throwException = true) { $model = DynamicModel::instantiate($fields, $rules); $model->load($attributes, ''); $model->validate(); if ($throwException && $model->hasErrors()) { throw new BadRequestHttpException(Json::encode($model->getErrors(), JSON_UNESCAPED_UNICODE)); } return $model; }
public function pushToList($from, array $to, $objectName, $content, $pushContent = null, $pushData = null, $count = null, $verifyBlacklist = 0, $isPersisted = 0, $isCounted = 0) { $params = ['fromUserId' => $this->getUserAlias($from), 'toUserId' => $this->getUserAliases($to), 'objectName' => $objectName, 'content' => $content, 'verifyBlacklist' => $verifyBlacklist, 'isPersisted' => $isPersisted, 'isCounted' => $isCounted]; if (null !== $pushContent) { $params['pushContent'] = $pushContent; } if (null !== $pushData) { $params['pushData'] = $pushData; } if (null !== $count) { $params['count'] = $count; } $response = $this->request('/message/private/publish', $params); $results = Json::decode($response, true); if (!isset($results['code']) || 200 != $results['code']) { throw new ResultException($response, '发送失败'); } return true; }