FormProtectionFactory

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

This class provides only static methods. It can not be instantiated.

Usage for the back-end form protection:

$formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();

Usage for the install tool form protection:

$formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();

Table of Contents

Properties

$instances  : array<string|int, AbstractFormProtection>
created instances of form protections using the type as array key

Methods

get()  : AbstractFormProtection
Gets a form protection instance for the requested type or class.
getMessageClosure()  : Closure
purgeInstances()  : mixed
Purges all existing instances.
set()  : mixed
Sets the instance that will be returned by get() for a specific class name.
createInstance()  : AbstractFormProtection
Creates an instance for the requested class $className and stores it internally.
getClassNameAndConstructorArgumentsByType()  : array<string|int, mixed>
Returns the class name and parameters depending on the given type.
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

get()

Gets a form protection instance for the requested type or class.

public static get([string $classNameOrType = 'default' ], array<int, mixed> ...$constructorArguments) : AbstractFormProtection

If there already is an existing instance of the requested $classNameOrType, the existing instance will be returned. If no $classNameOrType is provided, the factory detects the scope and returns the appropriate form protection object.

Parameters
$classNameOrType : string = 'default'

Name of a form protection class, or one of the pre-defined form protection types: frontend, backend, installtool

$constructorArguments : array<int, mixed>

Arguments for the class-constructor

Return values
AbstractFormProtection

the requested instance

purgeInstances()

Purges all existing instances.

public static purgeInstances() : mixed

This function is particularly useful when cleaning up in unit testing.

set()

Sets the instance that will be returned by get() for a specific class name.

public static set(string $classNameOrType, AbstractFormProtection $instance) : mixed

Note: This function is intended for testing purposes only.

Parameters
$classNameOrType : string
$instance : AbstractFormProtection
Internal

createInstance()

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

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

getClassNameAndConstructorArgumentsByType()

Returns the class name and parameters depending on the given type.

protected static getClassNameAndConstructorArgumentsByType(string $type) : array<string|int, mixed>

If the type cannot be used currently, protection is disabled.

Parameters
$type : string

Valid types: default, installtool, frontend, backend. "default" makes an autodetection on the current state

Return values
array<string|int, mixed>

Array of arguments

isBackendSession()

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

protected static isBackendSession() : bool
Return values
bool

isFrontendSession()

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

protected static isFrontendSession() : bool
Return values
bool

isInstallToolSession()

Check if we are in the install tool

protected static isInstallToolSession() : bool
Return values
bool

        
On this page

Search results