当前位置: 首页>>代码示例>>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;未经允许,请勿转载。