Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setQueryString example
$currentQueryString
=
$context
->
getQueryString
(
)
;
/* @var RouterContextStamp $contextStamp */
$context
->
setBaseUrl
(
$contextStamp
->
getBaseUrl
(
)
)
->
setMethod
(
$contextStamp
->
getMethod
(
)
)
->
setHost
(
$contextStamp
->
getHost
(
)
)
->
setScheme
(
$contextStamp
->
getScheme
(
)
)
->
setHttpPort
(
$contextStamp
->
getHttpPort
(
)
)
->
setHttpsPort
(
$contextStamp
->
getHttpsPort
(
)
)
->
setPathInfo
(
$contextStamp
->
getPathInfo
(
)
)
->
setQueryString
(
$contextStamp
->
getQueryString
(
)
)
;
try
{
return
$stack
->
next
(
)
->
handle
(
$envelope
,
$stack
)
;
}
finally
{
$context
->
setBaseUrl
(
$currentBaseUrl
)
->
setMethod
(
$currentMethod
)
->
setHost
(
$currentHost
)
->
setScheme
(
$currentScheme
)
->
setHttpPort
(
$currentHttpPort
)
private
array
$parameters
=
[
]
;
public
function
__construct
(
string
$baseUrl
= '', string
$method
= 'GET', string
$host
= 'localhost', string
$scheme
= 'http', int
$httpPort
= 80, int
$httpsPort
= 443, string
$path
= '/', string
$queryString
= ''
)
{
$this
->
setBaseUrl
(
$baseUrl
)
;
$this
->
setMethod
(
$method
)
;
$this
->
setHost
(
$host
)
;
$this
->
setScheme
(
$scheme
)
;
$this
->
setHttpPort
(
$httpPort
)
;
$this
->
setHttpsPort
(
$httpsPort
)
;
$this
->
setPathInfo
(
$path
)
;
$this
->
setQueryString
(
$queryString
)
;
}
public
static
function
fromUri
(
string
$uri
, string
$host
= 'localhost', string
$scheme
= 'http', int
$httpPort
= 80, int
$httpsPort
= 443
)
: self
{
$uri
=
parse_url
(
$uri
)
;
$scheme
=
$uri
[
'scheme'
]
??
$scheme
;
$host
=
$uri
[
'host'
]
??
$host
;
if
(
isset
(
$uri
[
'port'
]
)
)
{
if
(
'http' ===
$scheme
)
{
$httpPort
=
$uri
[
'port'
]
;
}
private
array
$parameters
=
[
]
;
public
function
__construct
(
string
$baseUrl
= '', string
$method
= 'GET', string
$host
= 'localhost', string
$scheme
= 'http', int
$httpPort
= 80, int
$httpsPort
= 443, string
$path
= '/', string
$queryString
= ''
)
{
$this
->
setBaseUrl
(
$baseUrl
)
;
$this
->
setMethod
(
$method
)
;
$this
->
setHost
(
$host
)
;
$this
->
setScheme
(
$scheme
)
;
$this
->
setHttpPort
(
$httpPort
)
;
$this
->
setHttpsPort
(
$httpsPort
)
;
$this
->
setPathInfo
(
$path
)
;
$this
->
setQueryString
(
$queryString
)
;
}
public
static
function
fromUri
(
string
$uri
, string
$host
= 'localhost', string
$scheme
= 'http', int
$httpPort
= 80, int
$httpsPort
= 443
)
: self
{
$uri
=
parse_url
(
$uri
)
;
$scheme
=
$uri
[
'scheme'
]
??
$scheme
;
$host
=
$uri
[
'host'
]
??
$host
;
if
(
isset
(
$uri
[
'port'
]
)
)
{
if
(
'http' ===
$scheme
)
{
$httpPort
=
$uri
[
'port'
]
;
}
public
function
testHost
(
)
{
$requestContext
=
new
RequestContext
(
)
;
$requestContext
->
setHost
(
'eXampLe.com'
)
;
$this
->
assertSame
(
'example.com',
$requestContext
->
getHost
(
)
)
;
}
public
function
testQueryString
(
)
{
$requestContext
=
new
RequestContext
(
)
;
$requestContext
->
setQueryString
(
null
)
;
$this
->
assertSame
(
'',
$requestContext
->
getQueryString
(
)
)
;
}
public
function
testPort
(
)
{
$requestContext
=
new
RequestContext
(
)
;
$requestContext
->
setHttpPort
(
'123'
)
;
$requestContext
->
setHttpsPort
(
'456'
)
;
$this
->
assertSame
(
123,
$requestContext
->
getHttpPort
(
)
)
;