W3cubDocs

/Symfony 4.1

CsrfExtension

class CsrfExtension extends AbstractExtension

This extension protects forms by using a CSRF token.

Methods

FormTypeInterface getType(string $name)

Returns a type by name.

from AbstractExtension
bool hasType(string $name)

Returns whether the given type is supported.

from AbstractExtension
FormTypeExtensionInterface[] getTypeExtensions(string $name)

Returns the extensions for the given type.

from AbstractExtension
bool hasTypeExtensions(string $name)

Returns whether this extension provides type extensions for the given type.

from AbstractExtension
FormTypeGuesserInterface|null getTypeGuesser()

Returns the type guesser provided by this extension.

from AbstractExtension
FormTypeInterface[] loadTypes()

Registers the types.

from AbstractExtension
FormTypeExtensionInterface[] loadTypeExtensions()

Registers the type extensions.

FormTypeGuesserInterface|null loadTypeGuesser()

Registers the type guesser.

from AbstractExtension
__construct(CsrfTokenManagerInterface $tokenManager, TranslatorInterface $translator = null, string $translationDomain = null)

Details

FormTypeInterface getType(string $name)

Returns a type by name.

Parameters

string $name The name of the type

Return Value

FormTypeInterface The type

Exceptions

InvalidArgumentException if the given type is not supported by this extension

bool hasType(string $name)

Returns whether the given type is supported.

Parameters

string $name The name of the type

Return Value

bool Whether the type is supported by this extension

FormTypeExtensionInterface[] getTypeExtensions(string $name)

Returns the extensions for the given type.

Parameters

string $name The name of the type

Return Value

FormTypeExtensionInterface[] An array of extensions as FormTypeExtensionInterface instances

bool hasTypeExtensions(string $name)

Returns whether this extension provides type extensions for the given type.

Parameters

string $name The name of the type

Return Value

bool Whether the given type has extensions

FormTypeGuesserInterface|null getTypeGuesser()

Returns the type guesser provided by this extension.

Return Value

FormTypeGuesserInterface|null The type guesser

protected FormTypeInterface[] loadTypes()

Registers the types.

Return Value

FormTypeInterface[] An array of FormTypeInterface instances

protected FormTypeExtensionInterface[] loadTypeExtensions()

Registers the type extensions.

Return Value

FormTypeExtensionInterface[] An array of FormTypeExtensionInterface instances

protected FormTypeGuesserInterface|null loadTypeGuesser()

Registers the type guesser.

Return Value

FormTypeGuesserInterface|null A type guesser

__construct(CsrfTokenManagerInterface $tokenManager, TranslatorInterface $translator = null, string $translationDomain = null)

Parameters

CsrfTokenManagerInterface $tokenManager The CSRF token manager
TranslatorInterface $translator The translator for translating error messages
string $translationDomain The translation domain for translating

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Form/Extension/Csrf/CsrfExtension.html