Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createStreamedResponseCallback example
return
tempnam
(
sys_get_temp_dir
(
)
,
uniqid
(
'symfony', true
)
)
;
}
public
function
createResponse
(
ResponseInterface
$psrResponse
, bool
$streamed
= false
)
: Response
{
$cookies
=
$psrResponse
->
getHeader
(
'Set-Cookie'
)
;
$psrResponse
=
$psrResponse
->
withoutHeader
(
'Set-Cookie'
)
;
if
(
$streamed
)
{
$response
=
new
StreamedResponse
(
$this
->
createStreamedResponseCallback
(
$psrResponse
->
getBody
(
)
)
,
$psrResponse
->
getStatusCode
(
)
,
$psrResponse
->
getHeaders
(
)
)
;
}
else
{
$response
=
new
Response
(
$psrResponse
->
getBody
(
)
->
__toString
(
)
,
$psrResponse
->
getStatusCode
(
)
,
$psrResponse
->
getHeaders
(
)
)
;
}
/** * {@inheritdoc} */
public
function
createResponse
(
ResponseInterface
$psrResponse
, bool
$streamed
= false
)
{
$cookies
=
$psrResponse
->
getHeader
(
'Set-Cookie'
)
;
$psrResponse
=
$psrResponse
->
withoutHeader
(
'Set-Cookie'
)
;
if
(
$streamed
)
{
$response
=
new
StreamedResponse
(
$this
->
createStreamedResponseCallback
(
$psrResponse
->
getBody
(
)
)
,
$psrResponse
->
getStatusCode
(
)
,
$psrResponse
->
getHeaders
(
)
)
;
}
else
{
$response
=
new
Response
(
$psrResponse
->
getBody
(
)
->
__toString
(
)
,
$psrResponse
->
getStatusCode
(
)
,
$psrResponse
->
getHeaders
(
)
)
;
}