final class CsrfViewHelper (View source)

Exposes session-backed CSRF tokens and escaped hidden fields to templates.

Methods

Connects template operations to the canonical token manager.

string
token(string $name = 'default')

Returns the stable session token associated with the requested logical name.

string
string
field(string $name = 'default')

Renders an escaped hidden input containing the requested session token.

string
string

Returns the public form field name recognized by the CSRF middleware.

string

Details

__construct

__construct(CsrfTokenManager $tokens)

Connects template operations to the canonical token manager.

Parameters

CsrfTokenManager $tokens

token

string token(string $name = 'default')

Returns the stable session token associated with the requested logical name.

Parameters

string $name

Return Value

string

field

string field(string $name = 'default')

Renders an escaped hidden input containing the requested session token.

Parameters

string $name

Return Value

string

fieldName

string fieldName()

Returns the public form field name recognized by the CSRF middleware.

Return Value

string