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


PHP ServerRequestInterface::getParam方法代码示例

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


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

示例1: createPost

 public function createPost(Request $request, Response $response)
 {
     $title = $request->getParam('title');
     $content = $request->getParam('content');
     $slug = trim($title);
     $slug = str_replace(' ', '-', $slug);
     $post = new Post();
     $post->setTitle($title);
     $post->setContent($content);
     $post->setSlug($slug);
     $this->em->persist($post);
     $this->em->flush();
     echo "Da them bai viet moi thanh cong";
 }
开发者ID:hak2c,项目名称:slim-doctrine-mvc,代码行数:14,代码来源:PostController.php

示例2: __invoke

 public function __invoke(Request $req, Response $res, $args = [])
 {
     $vaultName = $args['vaultName'];
     if (!($vault = Vault::get($vaultName))) {
         return $res->withStatus(404);
     }
     $operation = $req->getParam('operation');
     $postData = file_get_contents('php://input');
     $params = json_decode($postData, true);
     try {
         if ($operation === 'add') {
             if (empty($params['Tags'])) {
                 return $res->withStatus(400);
             }
             $vault->addTags($params['Tags']);
             return $res->withStatus(204);
         } elseif ($operation === 'remove') {
             if (empty($params['TagKeys'])) {
                 return $res->withStatus(204);
             }
             $vault->removeTags($params['TagKeys']);
             return $res->withStatus(204);
         }
         return $res->withStatus(400);
     } catch (\Gsandbox\Model\LimitExceededException $e) {
         return $res->limitExceededException();
     }
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:28,代码来源:SetTagsAction.php

示例3: signinUser

 public function signinUser(Request $request, Response $response)
 {
     $username = $request->getParam('username');
     $password = $request->getParam('password');
     $u = $this->em->getRepository('App\\Model\\User')->findOneBy(array('username' => $username));
     if ($u == []) {
         echo "Username nay khong ton tai";
     } else {
         if ($u->getPassword() != $password) {
             echo "Ban nhap sai password";
         } else {
             echo "Ban da dang nhap thanh cong";
         }
     }
     return $response;
 }
开发者ID:hak2c,项目名称:slim-doctrine-mvc,代码行数:16,代码来源:UserController.php

示例4: __invoke

 public function __invoke(ServerRequestInterface $requestInterface, ResponseInterface $responseInterface, callable $next)
 {
     $valid = $this->verify($requestInterface->getParam('g-recaptcha-response'), $requestInterface->getServerParams()['REMOTE_ADDR']);
     if ($valid) {
         return $next($requestInterface, $responseInterface);
     } else {
         throw new \Exception("Captcha Failed");
     }
 }
开发者ID:geggleto,项目名称:psr7-recaptcha,代码行数:9,代码来源:Captcha.php

示例5: authenticate

 public function authenticate(ServerRequestInterface $request, ResponseInterface $response)
 {
     if (empty($username = $request->getParam('username')) || empty($password = $request->getParam('password')) || empty($grant = $request->getParam('grant_type')) || $grant !== 'password') {
         throw (new OAuth2Exception('Invalid parameters supplied for authentication'))->displayMessage(OAuth2Exception::BAD_CREDENTIALS)->response($response->withStatus(401));
     }
     $result = $this->authRepo->validateCredentials($username, $password);
     if (empty($result)) {
         throw (new OAuth2Exception('Wrong username or password'))->displayMessage(OAuth2Exception::BAD_CREDENTIALS)->response($response->withStatus(401));
     }
     $address = $this->getAddress();
     $expiration = $this->getExpiration($this->config['expiration']);
     $builder = (new Builder())->setIssuer($address)->setAudience($address)->setId(md5(uniqid(mt_rand(), true)), true)->setIssuedAt(time())->setNotBefore(time() + 60)->setExpiration($expiration)->setSubject($result['id']);
     $customClaims = [];
     foreach ($result as $claim => $value) {
         if ($claim !== 'id') {
             $customClaims[] = $claim;
             $builder->set($claim, $value);
         }
     }
     $token = $builder->set('cc', implode(',', $customClaims))->sign(new Sha256(), new Key($this->config['private-key']))->getToken();
     // Retrieves the generated token
     return $response->withHeader(\HTTP\Header\CacheControl::name(), \HTTP\Header\CacheControl::values([\HTTP\Header\CacheControl::NO_CACHE, \HTTP\Header\CacheControl::REVALIDATE]))->writeJson(['token' => sprintf('%s', $token), 'type' => 'Bearer', 'expires' => $expiration]);
 }
开发者ID:marcoazn89,项目名称:oauth2-password-grant,代码行数:23,代码来源:OAuth2.php


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