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


PHP Request::getContent方法代码示例

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


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

示例1: request

 /**
  * @param string $name
  * @param mixed $default
  * @return mixed
  */
 public function request($name, $default = null)
 {
     //The RequestInterface expects this method to return values from a form submission or from
     //the decoded JSON body
     if ($this->data === null) {
         /* @var $contentType ContentType */
         $mediaType = $this->httpRequest->getHeaders('Content-type') ? $this->httpRequest->getHeaders('Content-type')->getFieldValue() : null;
         if ($mediaType == 'application/x-www-form-urlencoded' && ($this->httpRequest->isPut() || $this->httpRequest->isDelete())) {
             parse_str($this->httpRequest->getContent(), $this->data);
         } else {
             if ($mediaType == 'application/json' && ($this->httpRequest->isPost() || $this->httpRequest->isPut() || $this->httpRequest->isDelete())) {
                 $this->data = json_decode($this->httpRequest->getContent(), true);
             } else {
                 $this->data = $this->httpRequest->getPost()->toArray();
             }
         }
     }
     return isset($this->data[$name]) ? $this->data[$name] : $default;
 }
开发者ID:VictorAlencar,项目名称:zf2-oauth2-provider,代码行数:24,代码来源:RequestAdapter.php

示例2: createFromRequest

 public static function createFromRequest(BaseRequest $request)
 {
     $new = static::fromString($request->toString());
     $new->setQuery($request->getQuery());
     $new->setPost($request->getPost());
     $new->setCookies($request->getCookie());
     $new->setFiles($request->getFiles());
     $new->setServer($request->getServer());
     $new->setContent($request->getContent());
     $new->setEnv($request->getEnv());
     $headers = $request->getHeaders();
     $new->setHeaders($headers);
     return $new;
 }
开发者ID:diablomedia,项目名称:oauth2-server-zendhttp-bridge,代码行数:14,代码来源:Request.php

示例3: checkBody

 private function checkBody()
 {
     $content = parent::getContent();
     if (empty($content)) {
         return;
     }
     $json = json_decode($content, true);
     if (empty($json)) {
         throw new \Exception('Body Request is not a valid JSON' . "\n" . '(' . $content . ')');
     }
     foreach ($json as $name => $value) {
         if (!$this->checkParamName($name)) {
             throw new \Exception('Invalid param name (' . $name . ')');
         }
     }
     $this->bodyParameters = $json;
 }
开发者ID:rockeinstein,项目名称:library,代码行数:17,代码来源:ApiRequestImp.php

示例4: write

 /**
  * Запись логов
  * @param Request $request
  * @param Response $response
  */
 public function write($request, $response)
 {
     $serverOptions = $request->getServer()->toArray();
     $requestUri = isset($serverOptions['REQUEST_URI']) ? $serverOptions['REQUEST_URI'] : null;
     // Проверка на запись от правильного запроса
     if (is_null($requestUri) || !preg_match($this->_patternRequestWriteLog, $requestUri)) {
         return;
     }
     $remoteAddr = isset($serverOptions['REMOTE_ADDR']) ? $serverOptions['REMOTE_ADDR'] : '';
     $requestTime = isset($serverOptions['REQUEST_TIME']) ? $serverOptions['REQUEST_TIME'] : 0;
     $requestTimeFloat = isset($serverOptions['REQUEST_TIME_FLOAT']) ? $serverOptions['REQUEST_TIME_FLOAT'] : 0;
     /** @var DocumentManager $dm */
     $dm = $this->getServiceLocator()->get('doctrine-document');
     $logsClient = new LogsClient();
     $logsClient->setDatetime((new \DateTime())->setTimestamp($requestTime))->setHeaders($request->getHeaders()->toString())->setRequest($request->getContent())->setResponse($response->getContent())->setIpAddress($remoteAddr)->setDuration(round(microtime(true), 4) - $requestTimeFloat);
     $dm->persist($logsClient);
     $dm->flush();
 }
开发者ID:lexx7,项目名称:course,代码行数:23,代码来源:Logs.php

示例5: saveAction

 public function saveAction(Params $params, Request $request, Response $response, Form $form, Finder $finderService, Update $updateService, Form $form, View $view)
 {
     if ($request->getMethod() !== Request::METHOD_PUT) {
         return $view;
     }
     $id = $params('id');
     $entity = $finderService->find(['T4webTranslate' => ['Words' => ['Id' => (int) $id]]]);
     if (!$entity) {
         $response->setStatusCode(Response::STATUS_CODE_404);
         $view->setErrors(['message' => 'bad params']);
         return $view;
     }
     $data = Json::decode($request->getContent(), Json::TYPE_ARRAY);
     $form->setData($data);
     if (!$form->isValid()) {
         $response->setStatusCode(Response::STATUS_CODE_404);
         $view->setErrors($form->getMessages());
         return $view;
     }
     $entity->populate($data);
     $result = $updateService->update($id, $entity->extract());
     $view->setVariables($result->extract());
     return $view;
 }
开发者ID:sebaks,项目名称:Translate,代码行数:24,代码来源:AjaxWordController.php

示例6: switch

 }
 $requestMethod = $request->getMethod();
 /*
  * Types (Whenever new types are defined update this comment too)
  * AE => Add event
  * DE => Delete event
  * GE => Get Events
  * UE => Update Events
  * LI => Logged in status
  */
 switch (strtoupper($requestMethod)) {
     case 'AE':
         //validation
         //Todo-Ambuj Perform validation like check for name
         //if(empty($_POST['EventName']) || empty($_POST['EventDesc']) || empty($_POST['EventDate']) || empty($_POST['EventTime']) || empty($_POST['EventLocation']) || empty($_POST['EventDressCode'])) {
         $body = $request->getContent();
         if (!$body) {
             $validate = false;
             $response = Response::createMessage("01");
             break;
         }
         $data = json_decode($body, true);
         if (!$data) {
             $validate = false;
             $response = Response::createMessage("04");
             break;
         }
         if (empty($data["EventName"]) && empty($data["EventDesc"]) && empty($data["EventDate"]) && empty($data["EventTime"]) && empty($data["EventLocation"]) && empty($data["EventDressCode"])) {
             $validate = false;
             $response = Response::createMessage("01");
             break;
开发者ID:kbokdia,项目名称:DemoProject,代码行数:31,代码来源:controller.php


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