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


PHP ServerRequestInterface::isPost方法代碼示例

本文整理匯總了PHP中Psr\Http\Message\ServerRequestInterface::isPost方法的典型用法代碼示例。如果您正苦於以下問題:PHP ServerRequestInterface::isPost方法的具體用法?PHP ServerRequestInterface::isPost怎麽用?PHP ServerRequestInterface::isPost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Http\Message\ServerRequestInterface的用法示例。


在下文中一共展示了ServerRequestInterface::isPost方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loginAction

 public function loginAction(Request $request, Response $response, $args)
 {
     $hash = new Hash();
     if ($request->isPost()) {
         $data = $request->getParsedBody();
         try {
             $User = $this->em->getRepository('App\\Model\\Users')->findOneBy(['username' => $data['username']]);
         } catch (\Exception $e) {
             echo $e->getMessage();
             die;
         }
         if (is_null($User)) {
             $this->flash->addMessage('error', 'NAME FAIL');
         } else {
             $pass = $hash->create($data['password'], SALT);
             if ($User->getPassword() == $pass) {
                 $this->flash->addMessage('success', "SUCCESS !");
                 $_SESSION['user'] = ['username' => $User->getUsername(), 'email' => $User->getEmail(), 'role' => $User->getRole()];
             } else {
                 $this->flash->addMessage('error', "PASS FAIL !!!");
             }
         }
         return $response->withStatus(301)->withHeader('Location', '/');
     } else {
         $flash_success = $this->flash->getMessage('success');
         $flash_error = $this->flash->getMessage('error');
         $this->view->render($response, 'user/login.html', ['flash_success' => $flash_success, 'flash_error' => $flash_error]);
         return $response;
     }
 }
開發者ID:hak2c,項目名稱:phamthanhha_net,代碼行數:30,代碼來源:UserController.php

示例2: checkToken

 private function checkToken(ServerRequestInterface $request)
 {
     $params = $request->getQueryParams();
     if ($request->isPost()) {
         $params = $request->getParsedBody();
     }
     $token = $params['token'] ?: '';
     return false;
 }
開發者ID:sunpaolo,項目名稱:slim3Demo,代碼行數:9,代碼來源:AuthMiddleware.php

示例3: addPostAction

 public function addPostAction(Request $request, Response $response)
 {
     if ($request->isPost()) {
         $data = $request->getParsedBody();
         $title = $data['post_title'];
         $slug = trim($title);
         $slug = str_replace(' ', '-', $slug);
         $alias = $data['post_alias'];
         $content = $data['post_data'];
         $id = string($data['cat']);
         $post = new Posts();
         $post->setAlias($alias);
         $post->setCategory($id);
         $post->setPublished(true);
         $post->setSlug($slug);
         $post->setContent($content);
         $this->em->persist($post);
         $this->em->flush();
     }
     $this->view->render($response, 'admin/post/newpost.html', ['post' => $post]);
     return $response;
 }
開發者ID:hak2c,項目名稱:phamthanhha_net,代碼行數:22,代碼來源:PostController.php

示例4: edit

 public function edit(Request $request, Response $response, $args)
 {
     $data_form = $this->getIndicadorService()->getById($args['id']);
     $form = $this->getIndicadorForm();
     $form->setData($data_form);
     if ($request->isPost()) {
         $data_form = $request->getParsedBody();
         foreach ($data_form['fieldset_periodo'] as $key => $item) {
             $date = substr($item, -4) . '-' . substr($item, 0, 2) . '-01';
             $data_form['fieldset_periodo'][$key] = new \DateTime($date);
         }
         $form->setData($data_form);
         if ($form->isValid()) {
             $this->getIndicadorService()->save($data_form, $args['id']);
             return $response->withRedirect($this->router->pathFor('indicador'));
         } else {
             $form->setData($request->getParsedBody());
         }
     }
     $this->view->render($response, 'indicador/edit.twig', array('form' => $form));
     return $response;
 }
開發者ID:andrearruda,項目名稱:kpi,代碼行數:22,代碼來源:IndicadorAction.php


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