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


PHP ServerRequestInterface::getParsedBody方法代码示例

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


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

示例1: mainAction

 /**
  * Process add media request
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $files = $request->getParsedBody()['file'];
     $newMedia = [];
     if (isset($files['newMedia'])) {
         $newMedia = (array) $files['newMedia'];
     }
     foreach ($newMedia as $media) {
         if (!empty($media['url']) && !empty($media['target'])) {
             $allowed = !empty($media['allowed']) ? GeneralUtility::trimExplode(',', $media['allowed']) : [];
             $file = $this->addMediaFromUrl($media['url'], $media['target'], $allowed);
             if ($file !== null) {
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $file->getName(), $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.added'), FlashMessage::OK, true);
             } else {
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:online_media.error.invalid_url'), $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:online_media.error.new_media.failed'), FlashMessage::ERROR, true);
             }
             $this->addFlashMessage($flashMessage);
         }
     }
     $redirect = isset($request->getParsedBody()['redirect']) ? $request->getParsedBody()['redirect'] : $request->getQueryParams()['redirect'];
     $redirect = GeneralUtility::sanitizeLocalUrl($redirect);
     if ($redirect) {
         $response = $response->withHeader('Location', GeneralUtility::locationHeaderUrl($redirect))->withStatus(303);
     }
     return $response;
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:33,代码来源:OnlineMediaController.php

示例2: __invoke

 /**
  * @param Request $request
  * @param Response $response
  * @param callable $next
  * @return \Psr\Http\Message\MessageInterface|HtmlResponse
  * @throws Exception
  */
 public function __invoke(Request $request, Response $response, callable $next)
 {
     //$form = new LoginForm('Login', []);
     //$form->get('submit')->setValue('Login');
     if ($request->getMethod() == 'POST') {
         $auth = new AuthenticationService();
         $query = $request->getParsedBody();
         $authAdapter = new AuthAdapter($query['login'], $query['password'], $this->authConfig);
         $result = $auth->authenticate($authAdapter);
         if (!$result->isValid()) {
             //$response->getBody()->write("Not valid authentication\n");
             //return $response->withStatus(403)->withHeader("Content-type", 'text/html');
             throw new Exception("Not valid authentication\n", 403);
         } else {
             if ($request->getUri()->getPath() === '/auth') {
                 $render = $this->template->render('app::homepage');
                 $query = $request->getParsedBody();
                 $query['view']['render'] = $render;
                 $query['view']['code'] = 200;
                 $request = $request->withParsedBody($query);
             }
             return $next($request, $response);
         }
     } else {
         $render = $this->template->render('app::login', ['error' => null]);
         $query = $request->getParsedBody();
         $query['view']['render'] = $render;
         $query['view']['code'] = 200;
         $request = $request->withParsedBody($query);
         return $next($request, $response);
     }
 }
开发者ID:victorynox,项目名称:TestR,代码行数:39,代码来源:AuthenticationMiddleware.php

示例3: index

 /**
  * Index action shows install tool / step installer or redirect to action to enable install tool
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function index(ServerRequestInterface $request, ResponseInterface $response)
 {
     /** @var EnableFileService $enableFileService */
     $enableFileService = GeneralUtility::makeInstance(EnableFileService::class);
     /** @var AbstractFormProtection $formProtection */
     $formProtection = FormProtectionFactory::get();
     if ($enableFileService->checkInstallToolEnableFile()) {
         // Install tool is open and valid, redirect to it
         $response = $response->withStatus(303)->withHeader('Location', 'sysext/install/Start/Install.php?install[context]=backend');
     } elseif ($request->getMethod() === 'POST' && $request->getParsedBody()['action'] === 'enableInstallTool') {
         // Request to open the install tool
         $installToolEnableToken = $request->getParsedBody()['installToolEnableToken'];
         if (!$formProtection->validateToken($installToolEnableToken, 'installTool')) {
             throw new \RuntimeException('Given form token was not valid', 1369161225);
         }
         $enableFileService->createInstallToolEnableFile();
         // Install tool is open and valid, redirect to it
         $response = $response->withStatus(303)->withHeader('Location', 'sysext/install/Start/Install.php?install[context]=backend');
     } else {
         // Show the "create enable install tool" button
         /** @var StandaloneView $view */
         $view = GeneralUtility::makeInstance(StandaloneView::class);
         $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:install/Resources/Private/Templates/BackendModule/ShowEnableInstallToolButton.html'));
         $token = $formProtection->generateToken('installTool');
         $view->assign('installToolEnableToken', $token);
         /** @var ModuleTemplate $moduleTemplate */
         $moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
         $cssFile = 'EXT:install/Resources/Public/Css/BackendModule/ShowEnableInstallToolButton.css';
         $cssFile = GeneralUtility::getFileAbsFileName($cssFile);
         $moduleTemplate->getPageRenderer()->addCssFile(PathUtility::getAbsoluteWebPath($cssFile));
         $moduleTemplate->setContent($view->render());
         $response->getBody()->write($moduleTemplate->renderContent());
     }
     return $response;
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:42,代码来源:BackendModuleController.php

示例4: handle

 /**
  * @param Request $request
  * @return JsonResponse|EmptyResponse
  */
 public function handle(Request $request)
 {
     $actor = $request->getAttribute('actor');
     $Referer = $request->getHeader('Referer');
     $params = array_only($request->getParsedBody(), ['identification', 'password']);
     $response = $this->apiClient->send(TokenController::class, $actor, [], $params);
     if ($response->getStatusCode() === 200) {
         $data = json_decode($response->getBody());
         $session = $request->getAttribute('session');
         $this->authenticator->logIn($session, $data->userId);
         $token = AccessToken::find($data->token);
         event(new UserLoggedIn($this->users->findOrFail($data->userId), $token));
         $response = FigResponseCookies::set($response, SetCookie::create("lastLoginName")->withValue($request->getParsedBody()['identification'])->withPath('/'));
         $response = $this->rememberer->remember($response, $token);
     } elseif ($response->getStatusCode() === 401) {
         $responseNew = $this->apiClient->send(PingxxTokenController::class, $actor, [], $params);
         if ($responseNew->getStatusCode() === 200) {
             $data = json_decode($responseNew->getBody());
             $session = $request->getAttribute('session');
             $this->authenticator->logIn($session, $data->userId);
             $token = AccessToken::find($data->token);
             event(new UserLoggedIn($this->users->findOrFail($data->userId), $token));
             $responseNew = FigResponseCookies::set($responseNew, SetCookie::create("lastLoginName")->withValue($request->getParsedBody()['identification'])->withPath('/')->withDomain('dashboard.pingxx.com'));
             $responseNew = $this->rememberer->remember($responseNew, $token);
             return $responseNew;
         } else {
             return $response;
         }
     }
     return $response;
 }
开发者ID:go-wyvern,项目名称:pingxx-account,代码行数:35,代码来源:PingxxLoginController.php

示例5: isValid

 /**
  * @param string $name
  * @param array  $options
  *
  * @return bool
  */
 public function isValid($name, array $options = [])
 {
     $options += ['referer' => null, 'token' => null];
     if (null === $options['token']) {
         $params = $this->request->getParsedBody();
         if (!isset($params[$name])) {
             $this->invalidate();
             return false;
         } else {
             $options['token'] = $params[$name];
         }
     }
     $error = false;
     $name .= $options['token'];
     $config = array_get([self::TOKEN_KEY, $name], $this->storage, []);
     $time = isset($config['expire']) ? $config['expire'] : 0;
     if (time() > $time) {
         $error = true;
     }
     if (!$error && null !== $options['referer']) {
         $params = $this->request->getServerParams();
         if (!isset($params['HTTP_REFERER']) || $params['HTTP_REFERER'] !== $options['referer']) {
             $error = true;
         }
     }
     $regenerate = array_key_exists('regenerate', $config) ? $config['regenerate'] : false;
     if ($error || !$regenerate) {
         array_remove([self::TOKEN_KEY, $name], $this->storage);
     } elseif ($regenerate) {
         $config['expire'] = time() + $config['time'];
         array_set([self::TOKEN_KEY, $name], $config, $this->storage);
     }
     $this->invalidate();
     return !$error;
 }
开发者ID:cedtanghe,项目名称:elixir-security,代码行数:41,代码来源:CSRF.php

示例6: convertRequestFromPsr7

 /**
  * Converts a PSR-7 request into an OAuth2 request.
  *
  * @param ServerRequestInterface $psrRequest
  * @return Request
  */
 public static function convertRequestFromPsr7(ServerRequestInterface $psrRequest)
 {
     $headers = [];
     foreach ($psrRequest->getHeaders() as $header => $value) {
         $headers[$header] = implode(';', $value);
     }
     return new Request($psrRequest->getQueryParams(), is_array($psrRequest->getParsedBody()) ? $psrRequest->getParsedBody() : [], $psrRequest->getAttributes(), $psrRequest->getCookieParams(), self::getFiles($psrRequest->getUploadedFiles()), $psrRequest->getServerParams(), $psrRequest->getBody()->__toString(), $headers);
 }
开发者ID:tonis-io,项目名称:oauth2,代码行数:14,代码来源:Util.php

示例7: __construct

 /**
  * @param ServerRequestInterface $request
  * @param RouterInterface $router
  */
 public function __construct(ServerRequestInterface $request, RouterInterface $router)
 {
     $this->request = $request;
     parent::__construct($this);
     $this->parameters = $this->parseIncomingParams();
     $this->parameters = array_merge($this->parameters, $this->request->getParsedBody(), $this->getParsedAttributes($request, $router), $this->getQueryParams(), $this->request->getUploadedFiles());
     $this->parsedBody = array_merge(parent::getParsedBody(), $this->parameters);
 }
开发者ID:atasciuc,项目名称:zend-expressive-validation,代码行数:12,代码来源:RequestValidator.php

示例8: data

 /**
  * Get the data to be serialized and assigned to the response document.
  *
  * @param ServerRequestInterface $request
  * @param Document               $document
  * @return mixed
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $title = Arr::get($request->getParsedBody(), 'title');
     $start_post_id = Arr::get($request->getParsedBody(), 'start_post_id');
     $end_post_id = Arr::get($request->getParsedBody(), 'end_post_id');
     $actor = $request->getAttribute('actor');
     return $this->bus->dispatch(new SplitDiscussion($title, $start_post_id, $end_post_id, $actor));
 }
开发者ID:flagrow,项目名称:flarum-ext-split,代码行数:15,代码来源:SplitController.php

示例9: getHelpAction

 /**
  * The main dispatcher function. Collect data and prepare HTML output.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function getHelpAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $params = isset($request->getParsedBody()['params']) ? $request->getParsedBody()['params'] : $request->getQueryParams()['params'];
     if ($params['action'] === 'getContextHelp') {
         $result = $this->getContextHelp($params['table'], $params['field']);
         $response->getBody()->write(json_encode(['title' => $result['title'], 'content' => $result['description'], 'link' => $result['moreInfo']]));
     }
     return $response;
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:16,代码来源:ContextHelpAjaxController.php

示例10: processRequest

 /**
  * Renders/Echoes the ajax output
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface|NULL
  * @throws \InvalidArgumentException
  */
 public function processRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     $action = isset($request->getParsedBody()['action']) ? $request->getParsedBody()['action'] : (isset($request->getQueryParams()['action']) ? $request->getQueryParams()['action'] : '');
     if (!in_array($action, array('route', 'getAPI'), true)) {
         return null;
     }
     $this->routeAction($action);
     return $this->ajaxObject->render();
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:17,代码来源:ExtDirectEidController.php

示例11: validateCsrfToken

 /**
  * Validates CSRF token in given PSR-7 Request instance.
  *
  * @param ServerRequestInterface $request PSR-7 Request instance.
  *
  * @throws \Students\Exception\BadRequestException If CSRF check failed.
  *
  * @return boolean True if CSRF check was successful.
  */
 public function validateCsrfToken(ServerRequestInterface $request)
 {
     $formToken = isset($request->getParsedBody()['csrf']) ? strval($request->getParsedBody()['csrf']) : '';
     $cookie = FigRequestCookies::get($request, 'csrf');
     if ($cookie->getValue() !== $formToken) {
         throw new BadRequestException($request);
     }
     return true;
 }
开发者ID:foobar1643,项目名称:student-list,代码行数:18,代码来源:CSRFProtection.php

示例12: validate

 /**
  * Validates the request
  * @param ServerRequestInterface $requestInterface
  * @return bool|ValidationResult
  */
 public function validate(ServerRequestInterface $requestInterface)
 {
     $this->decoratedRequest = new RequestValidator($requestInterface, $this->router);
     $validatorProvider = $this->getValidatorObject($this->decoratedRequest);
     if ($validatorProvider == null) {
         return true;
     } else {
         return new ValidationResult($this->decoratedRequest->getParsedBody(), $validatorProvider, $this->entityManagerInterface, $this->decoratedRequest);
     }
 }
开发者ID:atasciuc,项目名称:zend-expressive-validation,代码行数:15,代码来源:Validator.php

示例13: __construct

 public function __construct(ServerRequestInterface $request)
 {
     $this->request = $request;
     if ($request->getParsedBody()) {
         $this->data = json_decode(json_encode($request->getParsedBody()), true);
     } else {
         $this->data = json_decode($request->getBody(), true);
     }
     $this->validateSchema();
 }
开发者ID:cass-project,项目名称:cass,代码行数:10,代码来源:SchemaParams.php

示例14: logoutAction

 /**
  * Injects the request object for the current request or subrequest
  * As this controller goes only through the main() method, it is rather simple for now
  * This will be split up in an abstract controller once proper routing/dispatcher is in place.
  *
  * @param ServerRequestInterface $request the current request
  * @param ResponseInterface $response
  * @return ResponseInterface the response with the content
  */
 public function logoutAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $this->logout();
     $redirectUrl = isset($request->getParsedBody()['redirect']) ? $request->getParsedBody()['redirect'] : $request->getQueryParams()['redirect'];
     $redirectUrl = GeneralUtility::sanitizeLocalUrl($redirectUrl);
     if (empty($redirectUrl)) {
         /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
         $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
         $redirectUrl = (string) $uriBuilder->buildUriFromRoute('login', array(), $uriBuilder::ABSOLUTE_URL);
     }
     return $response->withStatus(303)->withHeader('Location', GeneralUtility::locationHeaderUrl($redirectUrl));
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:21,代码来源:LogoutController.php

示例15: saveSortingState

 /**
  * Saves the sorting order of tasks in the backend user's uc
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function saveSortingState(ServerRequestInterface $request, ResponseInterface $response)
 {
     $sort = array();
     $data = isset($request->getParsedBody()['data']) ? $request->getParsedBody()['data'] : $request->getQueryParams()['data'];
     $items = explode('&', $data);
     foreach ($items as $item) {
         $sort[] = substr($item, 12);
     }
     $this->getBackendUserAuthentication()->uc['taskcenter']['sorting'] = serialize($sort);
     $this->getBackendUserAuthentication()->writeUC();
     return $response;
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:19,代码来源:TaskStatus.php


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