class RedirectResponse extends Response

跳转

return new RedirectResponse('/session/login');

Traits

ContainerAwareTrait

Methods

setContainer(ContainerInterface $container)

设置依赖注入容器

getContainer()

获取依赖注入容器

__construct(string $url, int $code = 302, string $message = null)

RedirectResponse constructor.

$this
setStatusCode(int $code, string $message = null)

设置响应状态

from Response
getContentType()

获取响应类型

from Response
$this
setContentType(string $contentType, string $charset = null)

设置响应类型

from Response
string|null
getContent()

获取响应内容

from Response
$this
setContent(string $content = null)

设置响应内容

from Response
array
getCookies()

获取响应的 cookies 信息

from Response
$this
setCookie(array $cookie)

设置响应的 cookie 信息

from Response
array
getHeaders()

获取响应的头信息

from Response
$this
setHeader(string $header, string $value = null)

设置响应头信息

from Response
$this
redirect(string $location = null, int $code = 302)

跳转

from Response
$this
send()

发送响应数据

from Response
$this
sendContent()

发送响应内容

from Response
$this
sendCookies()

发送响应 cookie

from Response
$this
sendHeaders()

发送响应头

from Response
string
getTargetUrl()

Returns the target URL.

$this
setTargetUrl(string $url)

Sets the redirect target of this response.

Details

in ContainerAwareTrait at line 22
setContainer(ContainerInterface $container)

设置依赖注入容器

Parameters

ContainerInterface $container 容器对象实例

in ContainerAwareTrait at line 32
ContainerInterface getContainer()

获取依赖注入容器

Return Value

ContainerInterface

at line 25
__construct(string $url, int $code = 302, string $message = null)

RedirectResponse constructor.

Parameters

string $url
int $code 状态码
string $message 状态描述

in Response at line 102
$this setStatusCode(int $code, string $message = null)

设置响应状态

Parameters

int $code 状态码
string $message 状态描述

Return Value

$this

in Response at line 113
getContentType()

获取响应类型

in Response at line 130
$this setContentType(string $contentType, string $charset = null)

设置响应类型

$response->setContentType('application/javascript');

Parameters

string $contentType
string $charset

Return Value

$this

in Response at line 147
string|null getContent()

获取响应内容

Return Value

string|null

in Response at line 159
$this setContent(string $content = null)

设置响应内容

Parameters

string $content

Return Value

$this

in Response at line 171
array getCookies()

获取响应的 cookies 信息

Return Value

array

in Response at line 183
$this setCookie(array $cookie)

设置响应的 cookie 信息

Parameters

array $cookie 单个 cookie 信息

Return Value

$this

in Response at line 206
array getHeaders()

获取响应的头信息

Return Value

array

in Response at line 219
$this setHeader(string $header, string $value = null)

设置响应头信息

Parameters

string $header
string $value

Return Value

$this

in Response at line 236
$this redirect(string $location = null, int $code = 302)

跳转

Parameters

string $location 跳转地址
int $code 状态码,默认 302 临时重定向

Return Value

$this

in Response at line 261
$this send()

发送响应数据

Return Value

$this

in Response at line 279
$this sendContent()

发送响应内容

Return Value

$this

in Response at line 291
$this sendCookies()

发送响应 cookie

Return Value

$this

in Response at line 313
$this sendHeaders()

发送响应头

Return Value

$this

at line 37
string getTargetUrl()

Returns the target URL.

Return Value

string target URL

at line 49
$this setTargetUrl(string $url)

Sets the redirect target of this response.

Parameters

string $url The URL to redirect to

Return Value

$this

Exceptions

InvalidArgumentException