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