本文整理汇总了PHP中yii\web\Request::post方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::post方法的具体用法?PHP Request::post怎么用?PHP Request::post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Request
的用法示例。
在下文中一共展示了Request::post方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
public function actionUpdate($id = 0)
{
// $out = ['status' => 'err', 'error' => 'Unknown error'];
if (\Yii::$app->user->isGuest) {
throw new NotFoundHttpException();
}
$r = new Request();
if (isset($r->post('Project')['id']) && $r->post('Project')['id']) {
$id = $r->post('Project')['id'];
}
// vd($r->post('Company'));
$userID = \Yii::$app->user->getId();
if ($id) {
$project = Project::findOne(['id' => $id, 'user_id' => $userID]);
} else {
$project = new Project();
// \Yii::$app->session->setFlash('error', 'Company ID is required.');
// $this->redirect(array('view','id'=>$company));
// $this->redirect(array('index'));
// return;
}
// vd($company);
if ($project) {
if ($project->load($r->post())) {
$project->user_id = $userID;
if ($project->validate() && $project->save()) {
//vd([$r->post(),$order->attributes]);
// $out = [
// 'status' => 'ok',
// 'order' => $order->id,
// 'user' => $order->user_id,
// 'sum' => $order->price / 100,
// ];
// $this->redirect(array('view','id'=>$company));
} else {
// vd($company->errors);
\Yii::$app->session->setFlash('error', array_values($project->errors)[0][0]);
// $out['error'] = array_values($order->errors)[0][0];
//vd($order->errors);
}
}
} else {
\Yii::$app->session->setFlash('error', 'Такой проект не существует');
$this->redirect(array('my'));
return;
}
return $this->render('update', ['project' => $project]);
// \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
// return $out;
/*vd(['get' => $r->getQueryParams() ,
'post' => $r->post(),
'order' => $order],1); //*/
}
示例2: testNoCData
public function testNoCData()
{
$request = new Request(['parsers' => ['application/xml' => XmlParser::className()]]);
$xml_body = '<xml><ToUserName>test</ToUserName></xml>';
$request->setRawBody($xml_body);
$result = $request->post();
$this->assertArrayHasKey('ToUserName', $result);
}
示例3: copyImage
/**
* 将临时文件夹中的图集,复制到指定目录下
* @author gaoqing
* 2016-02-24
* @param yii\web\Request $request request对象
* @param string $sourcePath 文件源路径
* @param string $destPath 目标文件路径
*/
public function copyImage($request, $sourcePath, $destPath)
{
$files = $request->post("files", "");
$files = trim($files, ",");
if (!empty($files)) {
$fileArr = explode(",", $files);
if (!empty($fileArr)) {
if (!file_exists($destPath) || !is_dir($destPath)) {
mkdir($destPath, 0777);
}
foreach ($fileArr as $file) {
$source = $sourcePath . DIRECTORY_SEPARATOR . $file;
$dest = $destPath . DIRECTORY_SEPARATOR . $file;
if (copy($source, $dest)) {
unlink($source);
}
}
}
}
}
示例4: getAddMapArr
/**
* 从 request 中,得到新增疾病信息的数组
* @author gaoqing
* 2016年1月15日
* @param Request $request 请求对象
* @param boolean $isAdd 是否是新增操作(默认是新增操作)
* @return array 新增疾病信息的数组
*/
private function getAddMapArr($request, $isAdd = true)
{
$addMapArr = [];
if ($request->post("disease", -1) != -1) {
$disease = $request->post("disease");
if ($isAdd) {
$pinyin_initial = Spell::Pinyin($disease['name'], 'utf-8', true);
$capital = strtoupper($pinyin_initial[0]);
$map_pinyin_sn = $this->getPinYinSnDic();
$pinyin_initial_sn = isset($map_pinyin_sn[$capital]) ? $map_pinyin_sn[$capital] + 1 : 0;
$addMapArr['disease'] = $this->setDefaultValues($disease, ['status' => 2, 'userid' => $this->user->id, 'username' => $this->user->login_name, 'inputtime' => time(), 'updatetime' => time(), 'type' => '0', 'capital' => $capital, 'capital_sn' => $pinyin_initial_sn, 'pinyin' => Spell::Pinyin($disease['name']), 'pinyin_initial' => $pinyin_initial, 'source_pinyin' => Spell::Pinyin($disease['name'])]);
} else {
$addMapArr['disease'] = $this->setDefaultValues($disease, ['userid' => $this->user->id, 'username' => $this->user->login_name, 'updatetime' => time()]);
}
}
if ($request->post("diseaseDepartment", -1) != -1) {
$diseaseDepartment = $request->post("diseaseDepartment");
$addMapArr['diseaseDepartment'] = $this->splitDatasByJSON($diseaseDepartment);
}
if ($request->post("diseaseDisease", -1) != -1) {
$diseaseDisease = $request->post("diseaseDisease");
$addMapArr['diseaseDisease'] = $this->splitDatas($diseaseDisease, "rel_diseaseid");
}
if ($request->post("diseaseSymptom", -1) != -1) {
$diseaseSymptom = $request->post("diseaseSymptom");
$addMapArr['diseaseSymptom'] = $this->splitDatas($diseaseSymptom, "symptomid");
}
if ($request->post("diseaseImage", -1) != -1) {
$diseaseImage = $request->post("diseaseImage");
$diseaseImage = $this->splitDatasByJSON($diseaseImage);
if (isset($diseaseImage) && !empty($diseaseImage)) {
foreach ($diseaseImage as $image) {
$singleImage = $this->setDefaultValues($image, ['flag' => 1, 'createtime' => time(), 'updatetime' => time()]);
$addMapArr['diseaseImage'][] = $singleImage;
}
}
}
if ($request->post("diseaseContent", -1) != -1) {
$addMapArr['diseaseContent'] = $request->post("diseaseContent");
}
return $addMapArr;
}
示例5: actionYadopay
public function actionYadopay()
{
\Yii::info('start', 'app/payments/yad');
$r = new Request();
$param = $r->post();
$code = 0;
$err_msg = null;
$order = null;
if (!$this->checkMD5($param)) {
// кривой md5
$code = 1;
//$err_msg = '';
} else {
$order = Order::chkOrder($param['orderNumber'], $param['customerNumber']);
if ($order) {
// ордер нашелся
if ($order->price < $param['orderSumAmount'] * 100) {
// и даже сумма норм
if ($param['action'] == 'paymentAviso' && !$order->closed_at) {
// это уже сам платеж и ордер не закрыт еще
// значит надо закрыть
$order->price = $param['orderSumAmount'] * 100;
$order->closed_at = new Expression('NOW()');
if ($order->validate() && $order->save()) {
// ok, все сохранилось
} else {
// что-то пошло не так
$code = 200;
$err_msg = array_values($order->errors)[0][0];
//vd($order->errors);
}
}
} else {
// сумма неправильная
$err_msg = 'Неверная сумма';
}
} else {
// нет такого ордера
$err_msg = 'Платеж не найден';
}
}
if (!$code && $err_msg) {
$code = 100;
}
// \Yii::$app->response->format = \yii\web\Response::FORMAT_XML;
$response = \Yii::$app->response;
$response->format = Response::FORMAT_RAW;
$response->getHeaders()->set('Content-Type', 'application/xml; charset=utf-8');
// return $this->render('sitemap');
return $this->buildResponse($param['action'], $param['invoiceId'], $code, $err_msg);
return $this->render('yadopay', ['response' => ['action' => $param['action'], 'invoiceId' => $param['invoiceId'], 'code' => $code, 'msg' => $err_msg, 'shopId' => $this->shopId], 'rrr' => ['param' => $param, 'order' => $order]]);
}
示例6: saveAllowance
/**
* Saves the number of allowed requests and the corresponding timestamp to a persistent storage.
* Do not need to check the Client ID & Access Token.
* @param Request $request the current request
* @param Action $action the action to be executed
* @param integer $allowance the number of allowed requests remaining.
* @param integer $timestamp the current timestamp.
*/
public function saveAllowance($request, $action, $allowance, $timestamp)
{
$access_token = \common\models\OauthAccessToken::findOne(['client_id' => $request->post('client_id'), 'access_token' => $request->post('access_token')]);
if (!$access_token) {
return false;
}
$endpoint = $action->controller->route;
$api_ratelimiter = ApiRatelimiter::findOne(['client_id' => $request->post('client_id'), 'api_endpoint' => $endpoint, 'user_uuid' => $access_token->user_uuid]);
if (!$api_ratelimiter) {
$api_ratelimiter = new ApiRatelimiter(['client_id' => $request->post('client_id'), 'api_endpoint' => $endpoint, 'user_uuid' => $access_token->user_uuid]);
}
$api_ratelimiter->allowed_remaining = $allowance;
$api_ratelimiter->last_timestamp = $timestamp;
return $api_ratelimiter->save();
}