本文整理汇总了PHP中Nette\Http\IRequest::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP IRequest::getQuery方法的具体用法?PHP IRequest::getQuery怎么用?PHP IRequest::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\IRequest
的用法示例。
在下文中一共展示了IRequest::getQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getQuery
/**
* @inheritdoc
*/
public function getQuery($key = NULL, $default = NULL)
{
if (func_num_args() === 0) {
return $this->current->getQuery();
}
return $this->current->getQuery($key, $default);
}
示例2: parseData
/**
* Parse data for input
* @return array
*
* @throws BadRequestException
*/
protected function parseData()
{
$postQuery = (array) $this->httpRequest->getPost();
$urlQuery = (array) $this->httpRequest->getQuery();
$requestBody = $this->parseRequestBody();
return array_merge($urlQuery, $requestBody, $postQuery);
}
示例3: send
/**
* Send JSONP response to output
* @param IRequest $httpRequest
* @param IResponse $httpResponse
* @throws \Drahak\Restful\InvalidArgumentException
*/
public function send(IRequest $httpRequest, IResponse $httpResponse)
{
$httpResponse->setContentType($this->contentType ? $this->contentType : 'application/javascript', 'UTF-8');
$data = array();
$data['response'] = $this->data;
$data['status'] = $httpResponse->getCode();
$data['headers'] = $httpResponse->getHeaders();
$callback = $httpRequest->getQuery('jsonp') ? Strings::webalize($httpRequest->getQuery('jsonp'), NULL, FALSE) : '';
echo $callback . '(' . $this->mapper->stringify($data, $this->isPrettyPrint()) . ');';
}
示例4: getParameters
/**
* Get all parameters
* @return array
*/
public function getParameters()
{
if (!$this->data) {
if ($this->request->getQuery()) {
$this->data = $this->request->getQuery();
} else {
if ($this->request->getPost()) {
$this->data = $this->request->getPost();
} else {
$this->data = $this->parseRequest(file_get_contents('php://input'));
}
}
}
return $this->data;
}
示例5: match
/**
* CLI commands run from app/console.php
*
* Maps HTTP request to a Request object.
* @return Nette\Application\Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
$this->loadLocales();
$urlPath = new Services\UrlPath($httpRequest);
$urlPath->setPredefinedLocales($this->locales);
/** @var Url $urlEntity */
$urlEntity = $this->loadUrlEntity($urlPath->getPath(true));
if ($urlEntity === null) {
// no route found
$this->onUrlNotFound($urlPath);
return null;
}
if ($urlEntity->getActualUrlToRedirect() === null) {
$presenter = $urlEntity->getPresenter();
$internal_id = $urlEntity->getInternalId();
$action = $urlEntity->getAction();
} else {
$presenter = $urlEntity->getActualUrlToRedirect()->getPresenter();
$internal_id = $urlEntity->getActualUrlToRedirect()->getInternalId();
$action = $urlEntity->getActualUrlToRedirect()->getAction();
}
$params = $httpRequest->getQuery();
$params['action'] = $action;
$params['locale'] = $urlPath->getLocale();
$this->urlParametersConverter->in($urlEntity, $params);
// todo
if ($internal_id !== null) {
$params['internal_id'] = $internal_id;
}
return new Nette\Application\Request($presenter, $httpRequest->getMethod(), $params, $httpRequest->getPost(), $httpRequest->getFiles());
}
示例6: match
/**
* Maps HTTP request to a Request object.
* @return Nette\Application\Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
if ($httpRequest->getUrl()->getPathInfo() !== '') {
return NULL;
}
// combine with precedence: get, (post,) defaults
$params = $httpRequest->getQuery();
$params += $this->defaults;
if (!isset($params[self::PRESENTER_KEY]) || !is_string($params[self::PRESENTER_KEY])) {
return NULL;
}
$presenter = $this->module . $params[self::PRESENTER_KEY];
unset($params[self::PRESENTER_KEY]);
return new Application\Request(
$presenter,
$httpRequest->getMethod(),
$params,
$httpRequest->getPost(),
$httpRequest->getFiles(),
array(Application\Request::SECURED => $httpRequest->isSecured())
);
}
示例7: match
/**
* Maps HTTP request to a Request object.
*
* @param Nette\Http\IRequest $httpRequest
* @return Request|NULL
*/
public function match(Nette\Http\IRequest $httpRequest)
{
$relativeUrl = trim($httpRequest->getUrl()->relativeUrl, "/");
$path = trim($httpRequest->getUrl()->path, "/");
if ($relativeUrl == "") {
$target = $this->defaultRoute;
$this->currentTarget->setCurrentTarget($this->targetDao->findTarget($target->presenter, $target->action, $target->id));
} elseif ($relativeUrl == "sitemap.xml") {
$target = new Target("Seo:Meta", "sitemap");
} elseif ($relativeUrl == "robots.txt") {
$target = new Target("Seo:Meta", "robots");
} elseif (substr($relativeUrl, 0, 6) == "google" && $this->settingsDao->getWebmasterToolsName() == $relativeUrl) {
$target = new Target("Seo:Meta", "googleWebmasterTools");
} else {
$route = $this->routeDao->findRouteBySlug($relativeUrl, TRUE);
if (!$route) {
$route = $this->routeDao->findRouteBySlug($path, TRUE);
if (!$route) {
return NULL;
}
}
$this->currentTarget->setCurrentTarget($route->getTarget());
$target = new Target($route->target->targetPresenter, $route->target->targetAction, $route->target->targetId);
}
$params = array();
$params["action"] = $target->action;
if ($target->id) {
$params["id"] = $target->id;
}
$params += $httpRequest->getQuery();
return new Request($target->presenter, $httpRequest->getMethod(), $params, $httpRequest->getPost(), $httpRequest->getFiles(), array(Request::SECURED => $httpRequest->isSecured()));
}
示例8: parse
/**
* @param Http\Request $request
* @return array
*/
private function parse(Http\IRequest $request)
{
$params = array_merge($request->getPost(), $request->getQuery());
if ($this->parser !== null) {
$parsed = $this->parser->parse($request->getRawBody());
$params = array_merge($params, $parsed);
}
return $params;
}
示例9: getRequest
/**
* @param string $key
* @param mixed $default
* @return mixed|null
*/
protected function getRequest($key, $default = NULL)
{
if ($value = $this->httpRequest->getPost($key)) {
return $value;
}
if ($value = $this->httpRequest->getQuery($key)) {
return $value;
}
return $default;
}
示例10: match
/**
* Maps HTTP request to a Request object.
* @return array|NULL
*/
public function match(Nette\Http\IRequest $request)
{
if ($request->getUrl()->getPathInfo() !== '') {
return NULL;
}
// combine with precedence: get, (post,) defaults
$params = $request->getQuery();
$params += $this->defaults;
return $params;
}
示例11: send
/**
* @param Nette\Http\IRequest $httpRequest
* @param Nette\Http\IResponse $httpResponse
* @throws \Nette\Application\BadRequestException
*/
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
{
$httpResponse->setContentType($this->contentType);
$httpResponse->setExpiration(FALSE);
$callback = $httpRequest->getQuery(self::$callbackName);
if (is_null($callback)) {
throw new \Nette\Application\BadRequestException("Invalid JSONP request.");
}
echo $callback . "(" . Nette\Utils\Json::encode($this->payload) . ")";
}
示例12: isPrettyPrint
/**
* Is pretty print enabled
* @param IRequest $request
* @return boolean
*/
protected function isPrettyPrint()
{
$prettyPrintKey = $this->request->getQuery($this->prettyPrintKey);
if ($prettyPrintKey === 'false') {
return FALSE;
}
if ($prettyPrintKey === 'true') {
return TRUE;
}
return $this->prettyPrint;
}
示例13: createPaginator
/**
* Create paginator
* @param int|null $offset
* @param int|null $limit
* @return Paginator
*
* @throws InvalidStateException
*/
protected function createPaginator($offset = NULL, $limit = NULL)
{
$offset = $this->request->getQuery('offset', $offset);
$limit = $this->request->getQuery('limit', $limit);
if ($offset === NULL || $limit === NULL) {
throw new InvalidStateException('To create paginator add offset and limit query parameter to request URL');
}
$paginator = new Paginator();
$paginator->setItemsPerPage($limit);
$paginator->setPage(floor($offset / $limit) + 1);
return $paginator;
}
示例14: getPreferredMethod
/**
* Get prederred method
* @param IRequest $request
* @return string
*/
protected function getPreferredMethod(IRequest $request)
{
$method = $request->getMethod();
$isPost = $method === IRequest::POST;
$header = $request->getHeader(self::OVERRIDE_HEADER);
$param = $request->getQuery(self::OVERRIDE_PARAM);
if ($header && $isPost) {
return $header;
}
if ($param && $isPost) {
return $param;
}
return $request->getMethod();
}
示例15: handleResponse
/**
* Signal for receive a response from gateway.
*/
public function handleResponse()
{
$data = $this->httpRequest->isMethod(IRequest::POST) ? $this->httpRequest->getPost() : $this->httpRequest->getQuery();
$response = NULL;
try {
$response = $this->client->receiveResponse($data);
} catch (Csob\Exception $e) {
if ($response === NULL && $e instanceof Csob\ExceptionWithResponse) {
$response = $e->getResponse();
}
$this->onError($this, $e, $response);
return;
}
$this->onResponse($this, $response);
}