本文整理汇总了PHP中Psr\Http\Message\ServerRequestInterface::getOriginalRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerRequestInterface::getOriginalRequest方法的具体用法?PHP ServerRequestInterface::getOriginalRequest怎么用?PHP ServerRequestInterface::getOriginalRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Http\Message\ServerRequestInterface
的用法示例。
在下文中一共展示了ServerRequestInterface::getOriginalRequest方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction(ServerRequestInterface $Request, ResponseInterface $Response, callable $Next = null)
{
$data = [];
$path = $Request->getOriginalRequest()->getUri()->getPath();
$pagdata = $this->getPaginationDataFromRequest($Request);
$entities = $this->storage->fetchAll('users');
$cnt = count($entities);
// If the requested page is later than the last, redirect to the last
/*if ($cnt && $pagdata['page'] > $cnt) {
return $Response
->withStatus(302)
->withHeader('Location', sprintf('%s?page-categories=%d', $path, $cnt));
}*/
$entities->setItemCountPerPage($pagdata['size']);
$entities->setCurrentPageNumber($pagdata['page']);
// $data['pages'] = iterator_to_array($pages->getItemsByPage($page));
$data['users'] = iterator_to_array($entities->getCurrentItems());
// pagination data
$data['pagination'] = [];
$data['pagination']['page'] = $pagdata['page'];
$data['pagination']['size'] = $pagdata['size'];
$data['pagination']['count'] = $cnt;
// return new JsonResponse($data);
return new HtmlResponse($this->template->render('user::list', $data));
// return new HtmlResponse($this->template->render('page::category-list', $data));
}
示例2: __invoke
public function __invoke(Request $request, Response $response, callable $next) : Response
{
$parent = $request->getOriginalRequest();
$parentUrl = str_replace('/thank-you', '', (string) $parent->getUri());
if (!$request->hasHeader('Referer') || !preg_match('#^' . $parentUrl . '#', $request->getHeaderLine('Referer'))) {
return $response->withStatus(302)->withHeader('Location', $parentUrl);
}
return new HtmlResponse($this->template->render('contact::thankyou', []));
}
示例3: __invoke
public function __invoke(Request $req, Response $res, callable $next) : Response
{
$tag = str_replace(['+', '%20'], ' ', $req->getAttribute('tag', ''));
$path = $req->getOriginalRequest()->getUri()->getPath();
$page = $this->getPageFromRequest($req);
$posts = $tag ? $this->mapper->fetchAllByTag($tag) : $this->mapper->fetchAll();
$posts->setItemCountPerPage(10);
// If the requested page is later than the last, redirect to the last
if (count($posts) && $page > count($posts)) {
return $res->withStatus(302)->withHeader('Location', sprintf('%s?page=%d', $path, count($posts)));
}
$posts->setCurrentPageNumber($page);
$pagination = $this->preparePagination($path, $page, $posts->getPages());
$entries = $this->prepareEntries($page, $posts);
return new HtmlResponse($this->template->render('blog::list', $this->prepareView($tag, $entries, $pagination)));
}
示例4: handle
/**
* @param Request $request
* @return \Psr\Http\Message\ResponseInterface|RedirectResponse
*/
public function handle(Request $request)
{
$redirectUri = $request->getOriginalRequest()->getUri()->withQuery('');
$session = $request->getAttribute('session');
$queryParams = $request->getQueryParams();
$oidSig = array_get($queryParams, 'openid_sig');
if (!$oidSig) {
return new RedirectResponse((string) (new Uri(SteamAuthController::LOGIN_URL))->withQuery(http_build_query(['openid.ns' => 'http://specs.openid.net/auth/2.0', 'openid.mode' => 'checkid_setup', 'openid.identity' => 'http://specs.openid.net/auth/2.0/identifier_select', 'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select', 'openid.return_to' => (string) $redirectUri, 'openid.realm' => (string) $redirectUri->withPath('')])));
}
$query = ['openid.ns' => 'http://specs.openid.net/auth/2.0', 'openid.sig' => array_get($queryParams, 'openid_sig')];
foreach (explode(',', array_get($queryParams, 'openid_signed')) as $param) {
$query['openid.' . $param] = array_get($queryParams, 'openid_' . $param);
}
// do not let overwrite this one via openid_signed
$query['openid.mode'] = 'check_authentication';
$client = new Client();
try {
$res = $client->request('POST', SteamAuthController::LOGIN_URL, ['form_params' => $query]);
} catch (Exception $e) {
return new Response("Can't Verify OpenID", 500);
}
if ($res->getStatusCode() === 200 and preg_match("/^is_valid:true+\$/im", (string) $res->getBody()) === 1) {
if ($steam_id = array_get($queryParams, 'openid_claimed_id') and $steam_id = basename($steam_id) and is_numeric($steam_id)) {
try {
$res = $client->request('GET', SteamAuthController::API_URL, ['query' => ['key' => $this->settings->get('sijad-auth-steam.api_key'), 'steamids' => $steam_id]]);
} catch (Exception $e) {
return new Response("Can't Get User Info", 500);
}
if ($info = json_decode((string) $res->getBody(), true)) {
$identification = ['steam_id' => $steam_id];
$suggestions = ['username' => $info['response']['players'][0]['personaname'], 'avatarUrl' => $info['response']['players'][0]['avatarfull']];
return $this->authResponse->make($request, $identification, $suggestions);
}
}
}
return new Response("Can't Get User Info", 500);
}
示例5: __invoke
public function __invoke(Request $request, Response $response, callable $next) : Response
{
$basePath = $request->getOriginalRequest()->getUri()->getPath();
$view = array_merge($this->config, ['action' => rtrim($basePath, '/') . '/process', 'csrf' => $this->session->getCsrfToken()->getValue()]);
return new HtmlResponse($this->template->render('contact::landing', $view));
}
示例6: redirect
private function redirect(Request $request, Response $response) : Response
{
$originalUri = $request->getOriginalRequest()->getUri();
$redirectUri = $originalUri->withPath('/');
return $response->withStatus(302)->withHeader('Location', (string) $redirectUri);
}
示例7: redisplayForm
private function redisplayForm(array $error, CsrfToken $csrfToken, Request $request) : Response
{
$csrfToken->regenerateValue();
$view = array_merge($this->config, ['error' => ['message' => json_encode($error)], 'action' => (string) $request->getOriginalRequest()->getUri(), 'csrf' => $csrfToken->getValue()]);
return new HtmlResponse($this->template->render('contact.landing', $view));
}