本文整理汇总了PHP中Symfony\Component\Routing\RequestContext::getQueryString方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestContext::getQueryString方法的具体用法?PHP RequestContext::getQueryString怎么用?PHP RequestContext::getQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Routing\RequestContext
的用法示例。
在下文中一共展示了RequestContext::getQueryString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFromRequest
public function testFromRequest()
{
$request = Request::create('https://test.com:444/foo?bar=baz');
$requestContext = new RequestContext();
$requestContext->setHttpPort(123);
$requestContext->fromRequest($request);
$this->assertEquals('', $requestContext->getBaseUrl());
$this->assertEquals('GET', $requestContext->getMethod());
$this->assertEquals('test.com', $requestContext->getHost());
$this->assertEquals('https', $requestContext->getScheme());
$this->assertEquals('/foo', $requestContext->getPathInfo());
$this->assertEquals('bar=baz', $requestContext->getQueryString());
$this->assertSame(123, $requestContext->getHttpPort());
$this->assertSame(444, $requestContext->getHttpsPort());
$request = Request::create('http://test.com:8080/foo?bar=baz');
$requestContext = new RequestContext();
$requestContext->setHttpsPort(567);
$requestContext->fromRequest($request);
$this->assertSame(8080, $requestContext->getHttpPort());
$this->assertSame(567, $requestContext->getHttpsPort());
}
示例2: rebuildRequest
/**
* Rebuild the request object from a URL with the help of the RequestContext.
*
* If the request context is not set, this simply returns the request object built from $uri.
*
* @param string $pathinfo
*
* @return Request
*/
private function rebuildRequest($pathinfo)
{
if (!$this->context) {
return Request::create('http://localhost' . $pathinfo);
}
$uri = $pathinfo;
$server = array();
if ($this->context->getBaseUrl()) {
$uri = $this->context->getBaseUrl() . $pathinfo;
$server['SCRIPT_FILENAME'] = $this->context->getBaseUrl();
$server['PHP_SELF'] = $this->context->getBaseUrl();
}
$host = $this->context->getHost() ?: 'localhost';
if ('https' === $this->context->getScheme() && 443 !== $this->context->getHttpsPort()) {
$host .= ':' . $this->context->getHttpsPort();
}
if ('http' === $this->context->getScheme() && 80 !== $this->context->getHttpPort()) {
$host .= ':' . $this->context->getHttpPort();
}
$uri = $this->context->getScheme() . '://' . $host . $uri . '?' . $this->context->getQueryString();
return Request::create($uri, $this->context->getMethod(), $this->context->getParameters(), array(), array(), $server);
}
示例3: testQueryString
public function testQueryString()
{
$requestContext = new RequestContext();
$requestContext->setQueryString(null);
$this->assertSame('', $requestContext->getQueryString());
}