本文整理汇总了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;
}