当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getParsedBody方法代码示例

本文整理汇总了PHP中Slim\Http\Request::getParsedBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getParsedBody方法的具体用法?PHP Request::getParsedBody怎么用?PHP Request::getParsedBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Http\Request的用法示例。


在下文中一共展示了Request::getParsedBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * Intermediario entre el Front-End y el servicio.
  *
  * @param Request $request
  *
  * @return []
  */
 public function login($request)
 {
     $result = [];
     $formData = $request->getParsedBody();
     $email = null;
     $password = null;
     // Verificamos que efectivamente exista una entrada de email
     if (array_key_exists("email", $formData)) {
         $email = $formData["email"];
     }
     // Verificamos que efectivamente exista una entrada de password
     if (array_key_exists("password", $formData)) {
         $password = $formData["password"];
     }
     if (isset($email, $password)) {
         $loginResult = $this->userService->login($email, $password);
         if (array_key_exists("error", $loginResult)) {
             $result["error"] = true;
         } else {
             setcookie($this->nombreCookie, true, time() + 3600);
         }
         $result["message"] = $loginResult["message"];
     } else {
         $result["error"] = true;
         $result["message"] = "Email and password can not be empty.";
     }
     return $result;
 }
开发者ID:meluk,项目名称:UProyecto1,代码行数:35,代码来源:UserController.php

示例2: edit

 public function edit(Request $request, Response $response, array $args)
 {
     $input = $request->getParsedBody();
     /** @var MemberPortfolios $portfolio */
     $portfolio = $this->data(MemberPortfolios::class);
     $validator = $this->validator->rule('required', ['company_name', 'industry_id', 'start_date_y', 'work_status', 'job_title', 'job_desc']);
     if ($input['work_status'] == 'R') {
         $validator->rule('required', 'end_date_y');
     }
     if ($validator->validate()) {
         if ($input['work_status'] == 'A') {
             unset($input['end_date_y'], $input['end_date_m'], $input['end_date_d']);
         }
         try {
             $update = $portfolio->update($input, (int) $args['id']);
             $message = 'Item portfolio berhasil diperbaharui. Selamat!';
         } catch (\PDOException $e) {
             $update = false;
             $message = 'System error!<br>' . $e->getMessage();
         }
         $this->addFormAlert($update !== false ? 'success' : 'error', $message);
     } else {
         $this->addFormAlert('warning', 'Some of mandatory fields is empty!', $validator->errors());
         return $response->withRedirect($this->router->pathFor('membership-portfolios-edit', $args));
     }
     return $response->withRedirect($this->router->pathFor('membership-account'));
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:27,代码来源:PortfoliosController.php

示例3: create

 /**
  * Create a new user with the data provided in the request body and return a JWT to start the User's session
  * @todo Figure out way to make exceptions more DRY, the way its currently set up each method would have all of these
  *       blocks.
  */
 public function create(Request $request, Response $response, array $args)
 {
     $logger = $this->getLogger();
     $data = $request->getParsedBody();
     $logger->addInfo('Creating new user', $data);
     $user = UserModel::create($data)->toArray();
     $jwt = ["email" => $user["email"], "id" => $user["uid"]];
     $jwt = $this->encodeJWT($jwt);
     return $response->withJson($jwt);
 }
开发者ID:folkevil,项目名称:Skeleton-API,代码行数:15,代码来源:User.php

示例4: createRelationsAction

 /**
  * Save organizations relations action
  *
  * @param Request $request
  * @param Response $response
  * @param array $args
  *
  * @return Response
  */
 public function createRelationsAction(Request $request, Response $response, $args)
 {
     // TODO: add validation for content type
     // TODO: add validation for data structure
     $relations = $request->getParsedBody();
     $relations = $this->serializer->deserialize($relations);
     $relations = $this->service->saveRelations($relations);
     $relations = $this->serializer->serialize($relations, Context::AS_TREE);
     return $response->withJson($relations, 201);
 }
开发者ID:EugeneKirillov,项目名称:organization-relationships,代码行数:19,代码来源:OrganizationsController.php

示例5: learningcenterPostEdit

 public function learningcenterPostEdit(Request $req, Response $res, $attr = [])
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     $postBody = $req->getParsedBody();
     $editParams = $this->adapterParams($postBody);
     if ($db->update("learningcenter", $editParams, ["id" => $attr["id"]]) !== false) {
         return $res->withHeader("Location", $req->getUri()->getBasePath() . "/learningcenter");
     }
     return $container->view->render($res, "learningcenter/form.twig", ["form" => $postBody]);
 }
开发者ID:nuiz,项目名称:gis,代码行数:11,代码来源:LearningCenterController.php

示例6: updateAction

 public function updateAction(Request $request, Response $response, array $args)
 {
     $data = $request->getParsedBody();
     $task = $this->_transformer->transformToModel($data);
     if ($task === null) {
         return $this->_infoPresenter->render($response, Presenter::STATUS_UNPROCESSABLE_ENTITY, Presenter::DESCRIPTION_INVALID_STRUCTURE);
     }
     $newTask = $this->_taskService->update($args['taskId'], $task);
     if ($newTask !== null) {
         return $this->_dataPresenter->render($response, Presenter::STATUS_ACCEPTED, $newTask);
     } else {
         return $this->_infoPresenter->render($response, Presenter::STATUS_NOT_FOUND, Presenter::DESCRIPTION_NONEXISTING_KEY);
     }
 }
开发者ID:Gerschtli,项目名称:time-manager,代码行数:14,代码来源:Task.php

示例7: teamAdd

 public function teamAdd(Request $request, Response $response, $args)
 {
     $data = $request->getParsedBody();
     /** @var EntityManager $em */
     $em = $this->container->entityManager;
     $team = new Team();
     $team->setName($data['name']);
     $team->setLeague($em->find('Fanta\\Entity\\League', $data['league_id']));
     $team->setUser($em->find('Fanta\\Entity\\User', $data['user_id']));
     $team->setName($data['name']);
     $em->persist($team);
     $em->flush();
     return $response->withRedirect($this->container->router->pathFor('league-detail', array('league_id' => $data['league_id'])));
 }
开发者ID:grisoni77,项目名称:Fanta-Slim-3-,代码行数:14,代码来源:Admin.php

示例8: accountPostEdit

 public function accountPostEdit(Request $req, Response $res, $attr = [])
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     $postBody = $req->getParsedBody();
     $editParams = $this->adapterParams($postBody);
     // var_dump($editParams); exit();
     if ($db->count("account", ["AND" => ["username" => @$postBody["username"], "id[!]" => $attr["id"]]]) > 0) {
         return $container->view->render($res, "account/form.twig", ["form" => $postBody, "error_message" => "ชื่อผู้ใช้งานซ้ำกับผู้ใช้งานอื่น"]);
     }
     if ($db->update("account", $editParams, ["id" => $attr["id"]]) !== false) {
         return $res->withHeader("Location", $req->getUri()->getBasePath() . "/account");
     }
     return $container->view->render($res, "account/form.twig", ["form" => $postBody]);
 }
开发者ID:nuiz,项目名称:gis,代码行数:15,代码来源:AccountController.php

示例9: login

 public function login(Request $request, $response, $args)
 {
     /** @var EntityManager $em */
     $em = $this->container->entityManager;
     $data = $request->getParsedBody();
     $user = $em->getRepository('Fanta\\Entity\\User')->findOneBy(array('name' => $data['user']));
     if (!$user) {
         return $response->withStatus(403, 'User not found');
     }
     if ($user->getPassword() != $this->container->auth->getEncryptedPassword($data['password'])) {
         return $response->withStatus(403, 'Incorrect password');
     }
     $this->container->session->createSession($user);
     return $response->withRedirect($this->container->router->pathFor('front-teams'));
 }
开发者ID:grisoni77,项目名称:Fanta-Slim-3-,代码行数:15,代码来源:Front.php

示例10: product_youtubePostAdd

 public function product_youtubePostAdd(Request $req, Response $res, $attr = [])
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     $postBody = $req->getParsedBody();
     // $insertParams = $this->adapterParams($postBody);
     $insertParams = [];
     $insertParams["product_id"] = $attr["product_id"];
     $insertParams["type"] = "youtube";
     $insertParams["youtube_id"] = $postBody["youtube_id"];
     $insertParams["sort_order"] = $db->max("product_media", "sort_order", ["AND" => ["product_id" => $attr["product_id"]]]) + 1;
     if (!$db->insert("product_media", $insertParams)) {
         return $res->withStatus(500)->withHeader('Content-Type', 'application/json')->write(json_encode(["error" => true]));
     }
     return $res->withStatus(200)->withHeader('Content-Type', 'application/json')->write(json_encode(["success" => true]));
 }
开发者ID:icezlizz1991,项目名称:tufftexgroup,代码行数:16,代码来源:ProductMediaController.php

示例11: register

 public function register(Request $request, Response $response, array $args)
 {
     /** @var Users $users */
     $users = $this->data(Users::class);
     $input = $request->getParsedBody();
     $validator = $this->validator->rule('required', ['email', 'username', 'fullname', 'password', 'repassword', 'job_id', 'gender_id', 'province_id', 'area']);
     $validator->addRule('assertEmailNotExists', function ($field, $value, array $params) use($users) {
         return !$users->assertEmailExists($value);
     }, 'tersebut sudah terdaftar! Silahkan gunakan email lain');
     $validator->addRule('assertUsernameNotExists', function ($field, $value, array $params) use($users) {
         $protected = ['admin', 'account', 'login', 'register', 'logout', 'activate', 'reactivate', 'regionals', 'forgot-password', 'reset-password'];
         return !in_array($value, $protected) && !$users->assertUsernameExists($value);
     }, 'tersebut sudah terdaftar! Silahkan gunakan username lain');
     $validator->rules(['regex' => [['fullname', ':^[A-z\\s]+$:'], ['username', ':^[A-z\\d\\-\\_]+$:']], 'email' => 'email', 'assertEmailNotExists' => 'email', 'assertUsernameNotExists' => 'username', 'dateFormat' => [['birth_date', 'Y-m-d']], 'equals' => [['repassword', 'password']], 'notIn' => [['username', 'password']], 'lengthMax' => [['username', 32], ['fullname', 64], ['area', 64]], 'lengthMin' => [['username', 6], ['password', 6]]]);
     if ($validator->validate()) {
         $emailAddress = $input['email'];
         $activationKey = md5(uniqid(rand(), true));
         $activationExpiredDate = date('Y-m-d H:i:s', time() + 172800);
         // 48 jam
         $registerSuccessMsg = 'Haayy <strong>' . $input['fullname'] . '</strong>,<br> Submission keanggotan sudah berhasil disimpan. Akan tetapi account anda tidak langsung aktif. Demi keamanan dan validitas data, maka sistem telah mengirimkan email ke email anda, untuk melakukan aktivasi account. Segera check email anda! Terimakasih ^_^';
         try {
             $input['activation_key'] = $activationKey;
             $input['expired_date'] = $activationExpiredDate;
             $input['fullname'] = ucwords($input['fullname']);
             $input['password'] = $this->salt($input['password']);
             if ($userId = $users->create($input)) {
                 $emailSettings = $this->settings->get('email');
                 $message = \Swift_Message::newInstance('PHP Indonesia - Aktivasi Membership')->setFrom([$emailSettings['sender_email'] => $emailSettings['sender_name']])->setTo([$emailAddress => $member['fullname']])->setBody(file_get_contents(APP_DIR . 'views' . _DS_ . 'email' . _DS_ . 'activation.txt'));
                 $this->mailer->registerPlugin(new \Swift_Plugins_DecoratorPlugin([$emailAddress => ['{email_address}' => $emailAddress, '{fullname}' => $input['fullname'], '{registration_date}' => date('d-m-Y H:i:s'), '{activation_path}' => $this->router->pathFor('membership-activation', ['uid' => $userId, 'activation_key' => $activationKey]), '{activation_expired_date}' => $activationExpiredDate, '{base_url}' => $request->getUri()->getBaseUrl()]]));
                 $this->mailer->send($message);
                 // Update email sent status
                 $this->data(UsersActivations::class)->update(['email_sent' => 'Y'], ['user_id' => $userId, 'activation_key' => $activationKey]);
             }
         } catch (\Swift_TransportException $e) {
             $registerSuccessMsg .= '<br><br><strong>Kemungkinan email akan sampai agak terlambat, karena email server kami sedang mengalami sedikit kendala teknis. Jika anda belum juga mendapatkan email, maka jangan ragu untuk laporkan kepada kami melalu email: report@phpindonesia.or.id</strong>';
         } catch (\PDOException $e) {
             $this->addFormAlert('error', 'System failed<br>' . $e->getMessage());
             return $response->withRedirect($this->router->pathFor('membership-register'));
         }
         $this->addFormAlert('success', $registerSuccessMsg);
     } else {
         $this->addFormAlert('warning', 'Some of mandatory fields is empty!', $validator->errors());
         return $response->withRedirect($this->router->pathFor('membership-register'));
     }
     return $response->withRedirect($this->router->pathFor('membership-index'));
 }
开发者ID:phpindonesia,项目名称:phpindonesia.or.id-membership2,代码行数:46,代码来源:HomeController.php

示例12: createGame

 /**
  *
  * @param Request $request
  *
  * @return []
  */
 public function createGame($request)
 {
     $result = [];
     /**
      *The content of `POST`
      *I get calling `getParsedBody`.
      */
     $formData = $request->getParsedBody();
     $title = null;
     $developer = null;
     $description = null;
     $console = null;
     $releaseDate = null;
     $rate = null;
     $url = null;
     // Verified that excites title
     if (array_key_exists("title", $formData)) {
         $title = $formData["title"];
     }
     // Verified that excites developer
     if (array_key_exists("developer", $formData)) {
         $developer = $formData["developer"];
     }
     // Verified that excites description
     if (array_key_exists("description", $formData)) {
         $description = $formData["description"];
     }
     // Verified that excites console
     if (array_key_exists("console", $formData)) {
         $console = $formData["console"];
     }
     // Verified that excites releaseDate
     if (array_key_exists("releaseDate", $formData)) {
         $releaseDate = $formData["releaseDate"];
     }
     // Verified that excites rate
     if (array_key_exists("rate", $formData)) {
         $rate = $formData["rate"];
     }
     // Verified that excites url
     if (array_key_exists("url", $formData)) {
         $url = $formData["url"];
     }
     return $this->gameService->createGame($title, $developer, $description, $console, $releaseDate, $rate, $url);
 }
开发者ID:meluk,项目名称:UProyecto1,代码行数:51,代码来源:gameController.php

示例13: sanitizeRequestBody

 /**
  * @param \Slim\Http\Request  $request
  * @param \Slim\Http\Response $response
  * @param callable            $next
  * @return mixed
  */
 public function sanitizeRequestBody(Request $request, Response $response, callable $next)
 {
     if ($inputs = $request->getParsedBody()) {
         $inputs = array_filter($inputs, function (&$value) {
             if (is_string($value)) {
                 $value = filter_var(trim($value), FILTER_SANITIZE_STRING);
             }
             return $value ?: null;
         });
         if (isset($inputs['_METHOD']) && $request->getMethod() == $inputs['_METHOD']) {
             unset($inputs['_METHOD']);
         }
         $request = $request->withParsedBody($inputs);
     }
     if ($request->getHeaderLine('Accept') == 'application/json') {
         $request = $request->withHeader('X-Requested-With', 'XMLHttpRequest');
     }
     return $next($request, $response);
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:25,代码来源:Middleware.php

示例14: add

 public function add(Request $request, Response $response, array $args)
 {
     $input = $request->getParsedBody();
     $requiredFields = ['skill_parent_id', 'skill_self_assesment'];
     if (isset($input['skill_id'])) {
         $requiredFields[] = 'skill_id';
     }
     $validator = $this->validator->rule('required', $requiredFields);
     if ($validator->validate()) {
         $users = $this->data(Users::class);
         $skills = $this->data(MemberSkills::class);
         $skills->create(['user_id' => $this->session->get('user_id'), 'skill_id' => $input['skill_id'] ?: $input['skill_parent_id'], 'skill_parent_id' => $input['skill_parent_id'], 'skill_self_assesment' => $input['skill_self_assesment']]);
         $this->addFormAlert('success', 'Item skill baru berhasil ditambahkan. Selamat!.  Silahkan tambahkan lagi item skill anda.');
     } else {
         $this->addFormAlert('warning', 'Some of mandatory fields is empty!', $validator->errors());
         return $response->withRedirect($this->router->pathFor('membership-skills-add'));
     }
     return $response->withRedirect($this->router->pathFor('membership-account'));
 }
开发者ID:tirta-keniten,项目名称:phpindonesia.or.id-membership2,代码行数:19,代码来源:SkillsController.php

示例15: login

 public function login(Request $request, Response $response, array $arguments)
 {
     $body = $request->getParsedBody();
     $user = User::where('email', $body['email'])->first();
     if (!$user) {
         return $response->withJson(['message' => 'no_such_email'], 400);
     }
     if (!password_verify($body['password'], $user->password)) {
         return $response->withJson(['message' => 'incorrect_password'], 400);
     }
     $factory = new Factory();
     $generator = $factory->getMediumStrengthGenerator();
     $tokenValue = $generator->generateString(128, Generator::CHAR_ALNUM);
     $token = new UserToken();
     $token->value = $tokenValue;
     $user->user_tokens()->save($token);
     $output = ['user' => $user, 'token' => $token->value];
     return $response->withJson($output, 200);
 }
开发者ID:joppuyo,项目名称:Dullahan,代码行数:19,代码来源:UserController.php


注:本文中的Slim\Http\Request::getParsedBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。