本文整理汇总了PHP中yii\web\Request::getBodyParams方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getBodyParams方法的具体用法?PHP Request::getBodyParams怎么用?PHP Request::getBodyParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Request
的用法示例。
在下文中一共展示了Request::getBodyParams方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* 从请求中获取值
* @param $key
* @param string $value
* @return string
*/
protected function get($key, $value = '')
{
$params = ArrayHelper::merge($_GET, $_POST);
$params = ArrayHelper::merge($params, $this->request->getBodyParams());
if (isset($params[$key])) {
return $params[$key];
}
return $value;
}
示例2: actionSuccesspay
public function actionSuccesspay()
{
// vd(['get' => Yii::$app->request->getQueryParams() ,
// 'post' => Yii::$app->request->getBodyParams()],1);
$r = new Request();
//Yii::info(\yii\helpers\Json::encode($requestData), 'apiRequest');
\Yii::info('[DEBUG_ME]' . print_r(['get' => $r->getQueryParams(), 'post' => $r->getBodyParams()], true), 'appDebug');
if ($r->post('action')) {
vd(['get' => $r->getQueryParams(), 'post' => $r->getBodyParams()], 1);
}
$order = Order::findOne($r->post('orderNumber'));
if ($order) {
} else {
vd($order);
}
$project = $order->project;
return $this->render('successpay', ['project' => $project]);
}
示例3: get
/**
* 从请求中获取值,包含POST和GET请求域以及通过php://input获取的数据
* @param $key
* @param string $value
* @return string
*/
protected function get($key, $value = '')
{
$params = ArrayHelper::merge($_GET, $_POST);
if (isset($params[$key])) {
return $params[$key];
}
foreach ($this->request->getBodyParams() as $k => $val) {
if (!isset($params[$k])) {
$params[$k] = $val;
}
}
if (isset($params[$key])) {
return $params[$key];
}
if ($this->request->getCookies()->has($key)) {
return $this->request->getCookies()->getValue($key);
}
return $value;
}
示例4: load
/**
* Loads query and post params into the model.
* @param ActiveRecord $model
* @param Request $request
* @return bool true if post params were loaded.
*/
protected function load($model, $request)
{
$model->load($request->getQueryParams());
return $model->load($request->getBodyParams());
}
示例5: setRequestParams
public function setRequestParams(Request $request)
{
$this->requestParams = array_merge($request->getQueryParams(), $request->getBodyParams());
}
示例6: load
/**
* 从请求域中加载数据
* @param \yii\web\Request $request
* @param string $formName
* @return bool
*/
public function load($request, $formName = null)
{
$data = $request->getBodyParams();
$keys = array_keys($this->getAttributes());
if ($formName == null) {
foreach ($keys as $key) {
if (isset($data[$key]) && !is_array($data[$key])) {
$this->setAttribute($key, $data[$key]);
}
}
return true;
} elseif (isset($data[$formName])) {
foreach ($keys as $key) {
if (isset($data[$formName][$key]) && !is_array($data[$formName][$key])) {
$this->setAttribute($key, $data[$formName][$key]);
}
}
return true;
} else {
return false;
}
}