TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\FormProtection\FormProtectionFactory Class Reference

Static Public Member Functions

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

Static Protected Member Functions

static getClassNameAndConstructorArgumentsByType ($type)
 
static isInstallToolSession ()
 
static isBackendSession ()
 
static isFrontendSession ()
 
static createInstance (array $classNameAndConstructorArguments)
 

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()

TYPO3\CMS\Core\FormProtection\FormProtectionFactory::__construct ( )
private

Private constructor to prevent instantiation.

Definition at line 56 of file FormProtectionFactory.php.

Member Function Documentation

◆ createInstance()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::createInstance ( array  $classNameAndConstructorArguments)
staticprotected

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

Parameters
array$classNameAndConstructorArguments
Exceptions

Definition at line 184 of file FormProtectionFactory.php.

◆ get()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get (   $classNameOrType = 'default')
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
Returns
the requested instance

Definition at line 72 of file FormProtectionFactory.php.

Referenced by TYPO3\CMS\Setup\Controller\SetupModuleController\__construct(), TYPO3\CMS\Core\Page\PageRenderer\addExtOnReadyCode(), TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromAjaxId(), TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromModule(), TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromRoute(), TYPO3\CMS\Backend\Controller\LoginController\checkRedirect(), TYPO3\CMS\Install\Controller\Action\Tool\ImportantActions\clearOpcodeCache(), TYPO3\CMS\Install\Controller\ToolController\execute(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\getForClassThatIsNoFormProtectionSubclassThrowsException(), TYPO3\CMS\Backend\Http\RouteDispatcher\getFormProtection(), TYPO3\CMS\Backend\Http\AjaxRequestHandler\getFormProtection(), TYPO3\CMS\Backend\Http\BackendModuleRequestHandler\getFormProtection(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\getForNotExistingClassThrowsException(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\getForTypeBackEndWithExistingBackEndReturnsBackEndFormProtection(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\getForTypeInstallToolCalledTwoTimesReturnsTheSameInstance(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\getForTypeInstallToolReturnsInstallToolFormProtection(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\getForTypesInstallToolAndDisabledReturnsDifferentInstances(), TYPO3\CMS\Backend\Utility\BackendUtility\getUrlToken(), TYPO3\CMS\Install\Controller\BackendModuleController\initializeAction(), TYPO3\CMS\Backend\AjaxLoginHandler\loginAction(), TYPO3\CMS\Core\Authentication\BackendUserAuthentication\logoff(), TYPO3\CMS\Install\Controller\AbstractController\outputLoginFormIfNotAuthorized(), TYPO3\CMS\Core\ExtDirect\ExtDirectRouter\routeAction(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\setNotSetsInstanceForOtherType(), and TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\setSetsInstanceForType().

◆ getClassNameAndConstructorArgumentsByType()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::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 93 of file FormProtectionFactory.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ isBackendSession()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::isBackendSession ( )
staticprotected

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

Returns
bool

Definition at line 139 of file FormProtectionFactory.php.

References $GLOBALS.

◆ isFrontendSession()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::isFrontendSession ( )
staticprotected

◆ isInstallToolSession()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::isInstallToolSession ( )
staticprotected

Check if we are in the install tool

Returns
bool

Definition at line 129 of file FormProtectionFactory.php.

◆ purgeInstances()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::purgeInstances ( )
static

Purges all existing instances.

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

Returns
void

Definition at line 220 of file FormProtectionFactory.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\tearDown(), and TYPO3\CMS\Core\Tests\Unit\Authentication\BackendUserAuthenticationTest\tearDown().

◆ set()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::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 208 of file FormProtectionFactory.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Authentication\BackendUserAuthenticationTest\logoffCleansFormProtectionIfBackendUserIsLoggedIn(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\setNotSetsInstanceForOtherType(), and TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\setSetsInstanceForType().

Member Data Documentation

◆ $instances

TYPO3\CMS\Core\FormProtection\FormProtectionFactory::$instances = []
staticprotected

Definition at line 51 of file FormProtectionFactory.php.