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


PHP Request::getQueryParams方法代码示例

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


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

示例1: __invoke

 /**
  * __invoke is called by slim when a route matches
  * @param $request Request
  * @param $response Response
  * @param $args array
  * *
  * @return $response \Slim\Http\Response
  */
 public function __invoke(Request $request, Response $response, array $args)
 {
     $this->response = $response;
     //check for api key
     $queryParams = $request->getQueryParams();
     if (isset($queryParams['api_key'])) {
         $userData = UserModel::getUserWithApiKey($queryParams['api_key']);
         if ($userData !== false) {
             $this->currentUser = new User($userData);
         }
     }
     $this->response = $this->response->withHeader('Content-type', 'application/json');
 }
开发者ID:JohnUiterwyk,项目名称:journey-planner,代码行数:21,代码来源:ApiController.php

示例2: viewPages

 /**
  * Generate pagination
  *
  * @return string
  */
 public function viewPages($totalData, $limit)
 {
     $parameter = '';
     $query_params = $this->request->getQueryParams();
     if ($query_params) {
         foreach ($query_params as $key => $param) {
             if ($key != 'page') {
                 if ($parameter == '') {
                     $parameter .= '?' . $key . '=' . $param;
                 } else {
                     $parameter .= '&' . $key . '=' . $param;
                 }
             }
         }
     }
     if ($parameter == '') {
         $parameter .= '?page=';
     } else {
         $parameter .= $parameter . '&page=';
     }
     if (empty($query_params['page'])) {
         $page = 1;
     } else {
         $page = $query_params['page'];
     }
     $count_page = ceil($totalData / $limit);
     $elements[] = '<ul class="pagination">';
     if ($page > 1) {
         $elements[] = '<li>';
         $elements[] = '<a href="' . $parameter . ($page - 1) . '" aria-label="Previous">';
         $elements[] = '<span aria-hidden="true">&laquo;</span>';
         $elements[] = '</a>';
         $elements[] = '</li>';
     }
     for ($i = 1; $i <= $count_page; $i++) {
         if ($i == $page) {
             $elements[] = ' <li><a href="#">' . $i . '</a></li>';
         } else {
             $elements[] = '<li><a href="' . $parameter . $i . '">' . $i . '</a></li>';
         }
     }
     if ($page < $count_page) {
         $elements[] = '<li>';
         $elements[] = '<a href="' . $parameter . ($page + 1) . '" aria-label="Previous">';
         $elements[] = '<span aria-hidden="true">&raquo;</span>';
         $elements[] = '</a>';
         $elements[] = '</li>';
     }
     $elements[] = '</ul>';
     return implode('', $elements);
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:56,代码来源:ViewExtension.php

示例3: authenticateCallback

 public function authenticateCallback(Request $request, Response $response)
 {
     $code = $request->getQueryParams()['code'] ?? '';
     try {
         if (!$code) {
             throw new \Exception('No access code provided.');
         }
         $token = $this->provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
         $this->helper->setAccessToken(['access_token' => $token->getToken(), 'expires' => $token->getExpires()]);
         return $response->withStatus(301)->withHeader('Location', '/' . self::AREA);
     } catch (\Exception $ex) {
         return $this->view->render($response, 'error.twig', ['error' => $ex->getMessage()]);
     }
 }
开发者ID:JosephMaxwell,项目名称:OAuth2Implementation,代码行数:14,代码来源:LibraryController.php

示例4: reportReg

 public function reportReg(Request $req, Response $res)
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     $queryParams = $req->getQueryParams();
     $cYear = $queryParams["year"] - 543;
     $where = [];
     $where["reg_date[>=]"] = $cYear . "-01-01 00:00:00";
     $where["reg_date[<=]"] = $cYear . "-12-31 23:59:59";
     $items = $db->select("person", "*", ["AND" => $where]);
     $objWriter = $this->makeExcelBypersons($items);
     // We'll be outputting an excel file
     header('Content-type: application/vnd.ms-excel');
     // It will be called file.xls
     header('Content-Disposition: attachment; filename="reg-' . $queryParams["year"] . '.xls"');
     // Write file to the browser
     $objWriter->save('php://output');
     exit;
 }
开发者ID:nuiz,项目名称:gis,代码行数:19,代码来源:ReportController.php

示例5: accounts

 public function accounts(Request $req, Response $res)
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     $queryParams = $req->getQueryParams();
     $where = [];
     $where["level"] = ["staff", "user"];
     $total = $db->count("account", $where);
     // count
     // item per page
     $perPage = 50;
     $maxPage = ceil($total / $perPage);
     $page = @$queryParams['page'] ? $queryParams['page'] : 1;
     $start = ($page - 1) * $perPage;
     $where["LIMIT"] = [$start, $perPage];
     // end count
     $where["ORDER"] = "id";
     $items = $db->select("account", "*", $where);
     return $container->view->render($res, "account/list.twig", ["form" => $queryParams, "items" => $items, "page" => $page, "maxPage" => $maxPage]);
 }
开发者ID:nuiz,项目名称:gis,代码行数:20,代码来源:AccountController.php

示例6: error

 /**
  * Simulate "error".
  *
  * Usage:
  * - <code>/test/error?debug=1</code> For testing develop mode (`displayErrorDetails = true`)
  * - <code>/test/error</code> For testing production mode (`displayErrorDetails = false`)
  *
  * @param Request $request The most recent Request object
  *
  * @throws Exception
  */
 public function error(Request $request)
 {
     $params = $request->getQueryParams();
     $this->settings['displayErrorDetails'] = (bool) ($params['develop'] ?? false);
     throw new Exception("Test");
 }
开发者ID:ansas,项目名称:slim-skeleton,代码行数:17,代码来源:TestController.php

示例7: personsSearch

 public function personsSearch(Request $req, Response $res)
 {
     $container = $this->slim->getContainer();
     $db = $container->medoo;
     // $session = $container->session;
     // $segment = $session->getSegment("login");
     // $segment->set("username", "papangping");
     // $session->commit();
     $oldersService = XMLService::getInstance("olders");
     $cripplesService = new CrippleService($db);
     $disavantagedsService = new DisavantagedService($db);
     $scholarsService = new ScholarService($db);
     $olders = $oldersService->gets();
     $cripples = $cripplesService->gets();
     $disavantageds = $disavantagedsService->gets();
     $scholars = $scholarsService->gets();
     $queryParams = $req->getQueryParams();
     $where = [];
     if (@$queryParams["is_older"] == "0" || @$queryParams["is_older"] == "1") {
         $where["is_older"] = $queryParams["is_older"];
     }
     if (!empty($queryParams["cripple_id"])) {
         $where["person_cripple.cripple_id"] = $queryParams["cripple_id"];
     }
     if (!empty($queryParams["disa_id"])) {
         $where["person_disavantaged.disavantaged_id"] = $queryParams["disa_id"];
     }
     if (!empty($queryParams["scho_id"])) {
         $where[".person_scholar.scholar_id"] = $queryParams["scho_id"];
     }
     if (!empty($queryParams["keyword"])) {
         $where["OR"] = [];
         $where["OR"]["first_name[~]"] = "%" . $queryParams["keyword"] . "%";
         $where["OR"]["last_name[~]"] = "%" . $queryParams["keyword"] . "%";
         $where["OR"]["card_id[~]"] = "%" . $queryParams["keyword"] . "%";
     }
     if (count($where) > 0) {
         $where = ["AND" => $where];
     }
     $join = ["[>]person_cripple" => ["id" => "person_id"], "[>]person_disavantaged" => ["id" => "person_id"], "[>]person_scholar" => ["id" => "person_id"]];
     $column = ["person.id", "person.card_id", "person.first_name", "person.last_name", "person.reg_date", "person.die_date", "person.birth_date", "person.is_older"];
     $total = $db->count("person", $join, "person.id", $where);
     // count
     // item per page
     $perPage = 50;
     $maxPage = ceil($total / $perPage);
     $page = @$queryParams['page'] ? $queryParams['page'] : 1;
     $start = ($page - 1) * $perPage;
     $where["LIMIT"] = [$start, $perPage];
     // end count
     $where["GROUP"] = "person.id";
     $where["ORDER"] = "person.card_id";
     $items = $db->select("person", $join, $column, $where);
     $this->buildItems($items);
     // hardcode for empty page
     if (count($where) <= 3) {
         $items = [];
     }
     return $container->view->render($res, "person/list_search.twig", ["form" => $queryParams, "items" => $items, "olders" => $olders, "cripples" => $cripples, "disavantageds" => $disavantageds, "scholars" => $scholars, "page" => $page, "maxPage" => $maxPage]);
 }
开发者ID:nuiz,项目名称:gis,代码行数:60,代码来源:PersonController.php

示例8: json

 /**
  * Output JSON info about the video.
  *
  * @param Request  $request  PSR-7 request
  * @param Response $response PSR-7 response
  *
  * @return Response HTTP response
  */
 public function json(Request $request, Response $response)
 {
     $params = $request->getQueryParams();
     if (isset($params['url'])) {
         try {
             $video = $this->download->getJSON($params['url']);
             return $response->withJson($video);
         } catch (\Exception $e) {
             return $response->withJson(['success' => false, 'error' => $e->getMessage()]);
         }
     }
 }
开发者ID:rudloff,项目名称:alltube,代码行数:20,代码来源:FrontController.php

示例9: authenticateCallback

 /**
  * Sends request:
  *      curl --data "code=[GET->code]
  *                   &grant_type=authorization_code
  *                   &client_id=[client_id]
  *                   &client_secret=[client_secret]
  *                   &redirect_uri=[url_of_this_function]"
  *            https://www.googleapis.com/oauth2/v3/token
  *
  * Gets response:
  * [
  *      'code' => '4/PTIwf4eUb3ajdD21_access_code'
  *      'scope' => 'https://www.googleapis.com/auth/drive.readonly'
  * ]
  * @param Request $request
  * @param Response $response
  * @return \Psr\Http\Message\MessageInterface|\Psr\Http\Message\ResponseInterface
  */
 public function authenticateCallback(Request $request, Response $response)
 {
     $code = $request->getQueryParams()['code'] ?? '';
     try {
         if (!$code) {
             throw new \Exception('No access code provided.');
         }
         $client = new Client();
         $params = ['code' => $code, 'grant_type' => 'authorization_code', 'client_id' => $this->config->getClientId(), 'client_secret' => $this->config->getClientSecret(), 'redirect_uri' => $this->helper->getCallbackUrl(self::AREA)];
         $response = $client->post($this->config->getTokenUri(), ['form_params' => $params]);
         $json = json_decode($response->getBody(), true);
         $this->helper->setAccessToken($json);
         if (!isset($json['access_token'])) {
             throw new \Exception("Access token not returned.");
         }
         return $response->withStatus(301)->withHeader('Location', '/' . self::AREA);
     } catch (\Exception $ex) {
         return $this->view->render($response, 'error.twig', ['error' => $ex->getMessage()]);
     }
 }
开发者ID:JosephMaxwell,项目名称:OAuth2Implementation,代码行数:38,代码来源:ManualController.php

示例10: editAlbum

 private function editAlbum(Request $request, Response $response)
 {
     $queryParams = $request->getQueryParams();
     if (isset($queryParams['id'])) {
         /* @var \App\models\Album $album */
         $album = $this->model->load('Album');
         $output = $album->filter(['id' => $queryParams['id'], 'user_id' => $this->user['id']])->fetch();
         if ($output) {
             $output['action'] = self::ACTION_EDIT;
             $output['isPublicOptions'] = $album->getIsPublicOptions();
             $output['photoId'] = $request->getParam('pid', 0);
             return $this->renderer->render($response, 'admin/edit_album.html', $output);
         } else {
             return $response->withStatus(302)->withHeader('Location ', $this->router->pathFor('admin_index'));
         }
     } else {
         return $response->withStatus(302)->withHeader('Location ', $this->router->pathFor('admin_index'));
     }
 }
开发者ID:wayne712,项目名称:slim-app,代码行数:19,代码来源:Admin.php

示例11: filterRequestMethod

 /**
  * This provide a method-overwrite for GET and POST request
  *
  * @param  \Slim\Http\Request $req
  * @return \Slim\Http\Request
  */
 protected function filterRequestMethod(Request $req)
 {
     $method = strtoupper($req->getMethod());
     $params = [];
     if ($method == 'GET') {
         $params = $req->getQueryParams();
     } elseif ($method == 'POST') {
         $params = $req->getParsedBody();
     }
     if (isset($params['_method'])) {
         $req = $req->withMethod($params['_method']);
     }
     return $req;
 }
开发者ID:ninjanero,项目名称:slim-skeleton,代码行数:20,代码来源:CommonMiddleware.php


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