本文整理匯總了PHP中Slim\Http\Request::getParsedBodyParam方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getParsedBodyParam方法的具體用法?PHP Request::getParsedBodyParam怎麽用?PHP Request::getParsedBodyParam使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Slim\Http\Request
的用法示例。
在下文中一共展示了Request::getParsedBodyParam方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
public function update(Request $request, Response $response, array $args)
{
/** @var Users $users */
$users = $this->data(Users::class);
$saltPass = $this->settings->get('salt_pwd');
$password = $request->getParsedBodyParam('password');
$validator = $this->validator->rule('required', ['oldpassword', 'password', 'repassword']);
$validator->addRule('check_oldpassword', function ($field, $value, array $params) use($users, $saltPass) {
$password = md5($saltPass . $value);
$countPass = $users->count(function ($query) use($password) {
$query->where('user_id', '=', $this->session->get('user_id'))->where('password', '=', $password);
});
return $countPass > 0;
}, 'Wrong! Please remember your old password');
$validator->rules(['check_oldpassword' => 'oldpassword', 'equals' => [['repassword', 'password']], 'lengthMin' => [['password', 6]]]);
if (!$validator->validate()) {
$this->addFormAlert('warning', 'Some of mandatory fields is empty!', $validator->errors());
return $response->withRedirect($this->router->pathFor('membership-account-password-edit'));
}
$users->update(['password' => $this->salt($password)], $this->session->get('user_id'));
$this->addFormAlert('success', 'Password anda berhasil diubah! Selamat!');
return $response->withRedirect($this->router->pathFor('membership-account'));
}
示例2: productFromCreateEditForm
/**
* Parses the POST request and creates the Product object
* @param Request $request
* @return Product
*/
protected function productFromCreateEditForm(Request $request)
{
$product = new Product();
$product->setId(intval($request->getParsedBodyParam('id', 0)))->setName($request->getParsedBodyParam('name', ''))->setDescription($request->getParsedBodyParam('description', ''));
$tags = explode(',', $request->getParsedBodyParam('tags', ''));
foreach ($tags as $tag) {
$tag = trim($tag);
// empty tag
if (!$tag) {
continue;
}
$product->addTag($tag);
}
return $product;
}