本文整理汇总了PHP中Nette\Http\Url::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::getQuery方法的具体用法?PHP Url::getQuery怎么用?PHP Url::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\Url
的用法示例。
在下文中一共展示了Url::getQuery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendBackgroundGetRequest
/**
* Funkce pro odeslání GET požadavku bez čekání na získání odpovědi
* @param string $url
* @throws \Exception
*/
public static function sendBackgroundGetRequest($url)
{
$url = new Url($url);
$host = $url->getHost();
if (empty($host)) {
$host = 'localhost';
}
#region parametry připojení
switch ($url->getScheme()) {
case 'https':
$scheme = 'ssl://';
$port = 443;
break;
case 'http':
default:
$scheme = '';
$port = 80;
}
$urlPort = $url->getPort();
if (!empty($urlPort)) {
$port = $urlPort;
}
#endregion
$fp = @fsockopen($scheme . $host, $port, $errno, $errstr, self::REQUEST_TIMEOUT);
if (!$fp) {
Debugger::log($errstr, ILogger::ERROR);
throw new \Exception($errstr, $errno);
}
$path = $url->getPath() . ($url->getQuery() != "" ? '?' . $url->getQuery() : '');
fputs($fp, "GET " . $path . " HTTP/1.0\r\nHost: " . $host . "\r\n\r\n");
fputs($fp, "Connection: close\r\n");
fputs($fp, "\r\n");
}
示例2: getParameters
/**
* @return array
*/
public function getParameters()
{
parse_str($this->url->getQuery(), $params);
return $params;
}
示例3: constructUrl
/**
* @param Request $appRequest
* @param Url $refUrl
* @return null|string
*/
public function constructUrl(Request $appRequest, Url $refUrl)
{
// one way can't generate link
if ($this->options['oneWay']) {
return NULL;
}
$params = $this->clearParameters($appRequest->getParameters());
$action = new Action($appRequest->getPresenterName() . ':' . $appRequest->getParameter('action'), $params);
// ISource return NULL, not found url to generate
if (($seoUrl = $this->source->toUrl($action)) === NULL) {
return NULL;
}
if (!$seoUrl instanceof Url) {
$seoUrl = new Url($seoUrl);
}
// host
if ($seoUrl->getHost()) {
$host = $refUrl->getHost();
$parts = ip2long($host) ? [$host] : array_reverse(explode('.', $host));
$host = strtr($seoUrl->getHost(), ['%tld%' => $parts[0], '%domain%' => isset($parts[1]) ? "{$parts['1']}.{$parts['0']}" : $parts[0], '%sld%' => isset($parts[1]) ? $parts[1] : '', '%host%' => $refUrl->getHost()]);
} else {
$host = $refUrl->getHost();
}
// path
$path = $seoUrl->getPath();
// query
$query = $seoUrl->getQueryParameters() + $params;
ksort($query);
$seoUrl->setQuery($query);
$query = $seoUrl->getQuery();
// fragment
$fragment = $seoUrl->getFragment();
return ($this->options['secured'] ? 'https' : 'http') . '://' . $host . $refUrl->getBasePath() . ($path === '/' ? '' : $path) . ($query ? '?' . $query : '') . ($fragment ? '#' . $fragment : '');
}
示例4: send
/**
* Send request
*
* @param string|null $resource Optional resource
* @param string|null $action Optional action
* @param array|null $values Optional values
* @param string|null $method Optional method
*
* @return array
*/
public function send($resource = null, $action = null, $values = null, $method = null)
{
if ($resource) {
$this->setResource($resource);
}
if ($action) {
$this->setAction($action);
}
if ($method) {
$this->setMethod($method);
}
if ($values) {
$this->setValues($values);
}
if ($this->method === self::POST || $this->method === self::PUT) {
$content = $this->values;
$url = new Url();
$url->setPath($this->getResource());
$url->setQuery(['action' => $this->getAction()]);
} else {
$content = [];
$url = new Url();
$url->setPath($this->getResource());
$url->setQuery(array_merge(['action' => $this->getAction()], $this->getValues()));
}
$result = $this->adapter->query($url->getPath() . '?' . $url->getQuery(), $this->method, $content);
if ($result->success === false) {
throw new Exception\AdapterException(json_encode($result->messages), (string) $url);
}
if (!isset($result->body)) {
throw new Exception\AdapterException('Body not provided in response!', (string) $url);
}
return ArrayUtils::objectToArray($result->body);
}