FormProtectionFactory

This class creates and manages instances of the various form protection classes.

Previously this class provides only provided static methods and could not be instantiated.

Since TYPO3 v12, this class can and should be used as a factory to be injected into other controllers or middlewares, to handle FormProtections for HTTP Requests.

Table of Contents

Properties

$flashMessageService  : FlashMessageService
$languageServiceFactory  : LanguageServiceFactory
$registry  : Registry
$runtimeCache  : FrontendInterface

Methods

__construct()  : mixed
createForType()  : AbstractFormProtection
Method should be used whenever you do not have direct access to the request object.
createFromRequest()  : AbstractFormProtection
Detect the right FormProtection implementation based on the request.
createInstance()  : AbstractFormProtection
Creates an instance for the requested class $className and stores it internally.
determineTypeFromRequest()  : string
Detects the type of FormProtection which should be instantiated, based on the request.
getClassNameAndConstructorArguments()  : array<string|int, mixed>
This is the equivalent to getClassNameAndConstructorArgumentsByType() but non-static.
getIdentifierForType()  : string
Conveniant method to create a deterministic cache identifier.
getMessageClosure()  : Closure
isBackendSession()  : bool
Checks if a user is logged in and the session is active.
isFrontendSession()  : bool
Checks if a frontend user is logged in and the session is active.
isInstallToolSession()  : bool
Check if we are in the install tool

Properties

Methods

createForType()

Method should be used whenever you do not have direct access to the request object.

public createForType(string $type) : AbstractFormProtection

It is however recommended to use createFromRequest() whenever you have a PSR-7 request object available.

Parameters
$type : string
Return values
AbstractFormProtection

createInstance()

Creates an instance for the requested class $className and stores it internally.

protected createInstance(class-string $className, array<int, mixed> ...$constructorArguments) : AbstractFormProtection
Parameters
$className : class-string
$constructorArguments : array<int, mixed>
Tags
throws
InvalidArgumentException
Return values
AbstractFormProtection

determineTypeFromRequest()

Detects the type of FormProtection which should be instantiated, based on the request.

protected determineTypeFromRequest(ServerRequestInterface $request) : string
Parameters
$request : ServerRequestInterface
Return values
string

getClassNameAndConstructorArguments()

This is the equivalent to getClassNameAndConstructorArgumentsByType() but non-static.

protected getClassNameAndConstructorArguments(string $type, ServerRequestInterface|null $request) : array<string|int, mixed>

It also does not handle "default" or class names, but is based on types previously resolved by the request. See determineTypeFromRequest()

Parameters
$type : string

Valid types: installtool, frontend, backend.

$request : ServerRequestInterface|null
Return values
array<string|int, mixed>

Array of arguments

getIdentifierForType()

Conveniant method to create a deterministic cache identifier.

protected getIdentifierForType(string $type) : string
Parameters
$type : string
Return values
string

isBackendSession()

Checks if a user is logged in and the session is active.

protected isBackendSession() : bool
Return values
bool

isFrontendSession()

Checks if a frontend user is logged in and the session is active.

protected isFrontendSession(ServerRequestInterface $request) : bool
Parameters
$request : ServerRequestInterface
Return values
bool

isInstallToolSession()

Check if we are in the install tool

protected isInstallToolSession(ServerRequestInterface $request) : bool
Parameters
$request : ServerRequestInterface
Return values
bool

        
On this page

Search results