TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
FormProtectionFactory Class Reference

Static Public Member Functions

static get ($classNameOrType= 'default',...$constructorArguments)
 
static set ($classNameOrType, AbstractFormProtection $instance)
 
static purgeInstances ()
 

Static Protected Member Functions

static getClassNameAndConstructorArgumentsByType ($type)
 
static isInstallToolSession ()
 
static isBackendSession ()
 
static isFrontendSession ()
 
static createInstance ($className,...$constructorArguments)
 

Static Protected Attributes

static $instances = []
 

Private Member Functions

 __construct ()
 

Detailed Description

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 = ::get();

Usage for the install tool form protection:

$formProtection = ::get();

Definition at line 44 of file FormProtectionFactory.php.

Constructor & Destructor Documentation

__construct ( )
private

Private constructor to prevent instantiation.

Definition at line 56 of file FormProtectionFactory.php.

Member Function Documentation

static createInstance (   $className,
  $constructorArguments 
)
staticprotected

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

Parameters
array$className
mixed$constructorArguments
Exceptions
InvalidArgumentException
Returns
AbstractFormProtection

Definition at line 186 of file FormProtectionFactory.php.

References GeneralUtility\makeInstance().

static get (   $classNameOrType = 'default',
  $constructorArguments 
)
static

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

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
string$classNameOrTypeName of a form protection class, or one of the pre-defined form protection types: frontend, backend, installtool
mixed$constructorArgumentsArguments for the class-constructor
Returns
the requested instance

Definition at line 73 of file FormProtectionFactory.php.

Referenced by SetupModuleController\__construct(), UriBuilder\buildUriFromAjaxId(), UriBuilder\buildUriFromModule(), UriBuilder\buildUriFromRoute(), LoginController\checkRedirect(), FormProtectionFactoryTest\getForClassThatIsNoFormProtectionSubclassThrowsException(), RouteDispatcher\getFormProtection(), AjaxRequestHandler\getFormProtection(), BackendModuleRequestHandler\getFormProtection(), FormProtectionFactoryTest\getForNotExistingClassThrowsException(), FormProtectionFactoryTest\getForTypeBackEndWithExistingBackEndReturnsBackEndFormProtection(), FormProtectionFactoryTest\getForTypeInstallToolCalledTwoTimesReturnsTheSameInstance(), FormProtectionFactoryTest\getForTypeInstallToolReturnsInstallToolFormProtection(), FormProtectionFactoryTest\getForTypesInstallToolAndDisabledReturnsDifferentInstances(), AjaxLoginHandler\loginAction(), BackendUserAuthentication\logoff(), ExtDirectRouter\routeAction(), FormProtectionFactoryTest\setNotSetsInstanceForOtherType(), and FormProtectionFactoryTest\setSetsInstanceForType().

static getClassNameAndConstructorArgumentsByType (   $type)
staticprotected

Returns the class name and parameters depending on the given type. If the type cannot be used currently, protection is disabled.

Parameters
string$typeValid types: default, installtool, frontend, backend. "default" makes an autodection on the current state
Returns
array Array of arguments

Definition at line 94 of file FormProtectionFactory.php.

References $GLOBALS, and GeneralUtility\makeInstance().

static isBackendSession ( )
staticprotected

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

Returns
bool

Definition at line 140 of file FormProtectionFactory.php.

References $GLOBALS.

static isFrontendSession ( )
staticprotected

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

Returns
bool

Definition at line 150 of file FormProtectionFactory.php.

References $GLOBALS.

static isInstallToolSession ( )
staticprotected

Check if we are in the install tool

Returns
bool

Definition at line 130 of file FormProtectionFactory.php.

static purgeInstances ( )
static

Purges all existing instances.

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

Returns
void

Definition at line 221 of file FormProtectionFactory.php.

Referenced by FormProtectionFactoryTest\tearDown(), and BackendUserAuthenticationTest\tearDown().

static set (   $classNameOrType,
AbstractFormProtection  $instance 
)
static

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

Note: This function is intended for testing purposes only.

private

Parameters
string$classNameOrType
AbstractFormProtection$instance
Returns
void

Definition at line 209 of file FormProtectionFactory.php.

Referenced by FormProtectionFactoryTest\setNotSetsInstanceForOtherType(), and FormProtectionFactoryTest\setSetsInstanceForType().

Member Data Documentation

$instances = []
staticprotected

Definition at line 51 of file FormProtectionFactory.php.