當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::getParsedBodyParam方法代碼示例

本文整理匯總了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'));
 }
開發者ID:phpindonesia,項目名稱:phpindonesia.or.id-membership2,代碼行數:23,代碼來源:PasswordController.php

示例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;
 }
開發者ID:elegos,項目名稱:PHPTest,代碼行數:20,代碼來源:ProductController.php


注:本文中的Slim\Http\Request::getParsedBodyParam方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。