‪TYPO3CMS  10.4
TYPO3\CMS\Core\FormProtection\FormProtectionFactory Class Reference

Static Public Member Functions

static TYPO3 CMS Core FormProtection AbstractFormProtection get ($classNameOrType='default',... $constructorArguments)
 
static Closure getMessageClosure (LanguageService $languageService, FlashMessageQueue $messageQueue, $isAjaxCall)
 
static set ($classNameOrType, AbstractFormProtection $instance)
 
static purgeInstances ()
 

Static Protected Member Functions

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

Static Protected Attributes

static array< AbstractFormProtection$instances = array( )
 

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 = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();

Usage for the install tool form protection:

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

Definition at line 46 of file FormProtectionFactory.php.

Constructor & Destructor Documentation

◆ __construct()

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

Private constructor to prevent instantiation.

Definition at line 57 of file FormProtectionFactory.php.

Member Function Documentation

◆ createInstance()

static AbstractFormProtection TYPO3\CMS\Core\FormProtection\FormProtectionFactory::createInstance (   $className,
  $constructorArguments 
)
staticprotected

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

Parameters
string$className
array<int,mixed>‪$constructorArguments
Exceptions

Definition at line 187 of file FormProtectionFactory.php.

Referenced by TYPO3\CMS\Core\FormProtection\FormProtectionFactory\get().

◆ get()

static TYPO3 CMS Core FormProtection AbstractFormProtection TYPO3\CMS\Core\FormProtection\FormProtectionFactory::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$classNameOrType‪Name of a form protection class, or one of the pre-defined form protection types: frontend, backend, installtool
array<int,mixed>‪$constructorArguments Arguments for the class-constructor
Returns
‪\TYPO3\CMS\Core\FormProtection\AbstractFormProtection the requested instance

Definition at line 74 of file FormProtectionFactory.php.

References TYPO3\CMS\Core\FormProtection\FormProtectionFactory\createInstance(), and TYPO3\CMS\Core\FormProtection\FormProtectionFactory\getClassNameAndConstructorArgumentsByType().

Referenced by TYPO3\CMS\Setup\Controller\SetupModuleController\__construct(), TYPO3\CMS\Backend\Routing\UriBuilder\buildUriFromRoute(), TYPO3\CMS\Install\Controller\SettingsController\changeInstallToolPasswordGetDataAction(), TYPO3\CMS\Backend\Controller\LoginController\checkRedirect(), TYPO3\CMS\Install\Middleware\Maintenance\checkSessionToken(), TYPO3\CMS\Install\Controller\MaintenanceController\clearTablesStatsAction(), TYPO3\CMS\Install\Controller\MaintenanceController\clearTypo3tempFilesStatsAction(), TYPO3\CMS\Install\Controller\MaintenanceController\createAdminGetDataAction(), TYPO3\CMS\Install\Controller\MaintenanceController\databaseAnalyzerAction(), TYPO3\CMS\Install\Controller\InstallerController\executeDefaultConfigurationAction(), TYPO3\CMS\Install\Controller\UpgradeController\extensionCompatTesterLoadedExtensionListAction(), TYPO3\CMS\Install\Controller\SettingsController\extensionConfigurationGetContentAction(), TYPO3\CMS\Install\Controller\UpgradeController\extensionScannerGetDataAction(), TYPO3\CMS\Install\Controller\SettingsController\featuresGetContentAction(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\getForClassThatIsNoFormProtectionSubclassThrowsException(), TYPO3\CMS\Backend\Http\RouteDispatcher\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\Install\Controller\MaintenanceController\languagePacksGetDataAction(), TYPO3\CMS\Install\Controller\SettingsController\localConfigurationGetContentAction(), TYPO3\CMS\Backend\Controller\AjaxLoginController\loginAction(), TYPO3\CMS\Core\Authentication\BackendUserAuthentication\logoff(), TYPO3\CMS\Install\Controller\EnvironmentController\mailTestGetDataAction(), TYPO3\CMS\Install\Controller\SettingsController\presetsGetContentAction(), TYPO3\CMS\Install\Middleware\Installer\process(), TYPO3\CMS\Install\Middleware\Maintenance\process(), TYPO3\CMS\Backend\Controller\LogoutController\processLogout(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\setNotSetsInstanceForOtherType(), TYPO3\CMS\Core\Tests\Unit\FormProtection\FormProtectionFactoryTest\setSetsInstanceForType(), TYPO3\CMS\Install\Controller\InstallerController\showDatabaseConnectAction(), TYPO3\CMS\Install\Controller\InstallerController\showDatabaseDataAction(), TYPO3\CMS\Install\Controller\InstallerController\showDatabaseSelectAction(), TYPO3\CMS\Install\Controller\InstallerController\showDefaultConfigurationAction(), TYPO3\CMS\Install\Controller\LoginController\showLoginAction(), TYPO3\CMS\Install\Controller\SettingsController\systemMaintainerGetListAction(), TYPO3\CMS\Install\Controller\UpgradeController\upgradeDocsGetContentAction(), and TYPO3\CMS\Install\Controller\UpgradeController\upgradeWizardsGetDataAction().

◆ getClassNameAndConstructorArgumentsByType()

static array 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$type‪Valid types: default, installtool, frontend, backend. "default" makes an autodetection on the current state
Returns
‪array Array of arguments

Definition at line 95 of file FormProtectionFactory.php.

References $GLOBALS, and TYPO3\CMS\Core\FormProtection\FormProtectionFactory\getMessageClosure().

Referenced by TYPO3\CMS\Core\FormProtection\FormProtectionFactory\get().

◆ getMessageClosure()

static Closure TYPO3\CMS\Core\FormProtection\FormProtectionFactory::getMessageClosure ( LanguageService  $languageService,
FlashMessageQueue  $messageQueue,
  $isAjaxCall 
)
static
Parameters
LanguageService$languageService
FlashMessageQueue$messageQueue
bool$isAjaxCall

Only public to be used in tests

Returns
‪\Closure

Definition at line 163 of file FormProtectionFactory.php.

References TYPO3\CMS\Core\Messaging\FlashMessageQueue\enqueue(), TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR, and TYPO3\CMS\Core\Localization\LanguageService\sL().

Referenced by TYPO3\CMS\Core\FormProtection\FormProtectionFactory\getClassNameAndConstructorArgumentsByType().

◆ isBackendSession()

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

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

Returns
‪bool

Definition at line 141 of file FormProtectionFactory.php.

References $GLOBALS.

◆ isFrontendSession()

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

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

Returns
‪bool

Definition at line 151 of file FormProtectionFactory.php.

References $GLOBALS.

◆ isInstallToolSession()

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

Check if we are in the install tool

Returns
‪bool

Definition at line 131 of file FormProtectionFactory.php.

◆ purgeInstances()

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

◆ set()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::set (   $classNameOrType,
AbstractFormProtection  $instance 
)
static

Member Data Documentation

◆ $instances

array<AbstractFormProtection> TYPO3\CMS\Core\FormProtection\FormProtectionFactory::$instances = array( )
staticprotected

created instances of form protections using the type as array key

Definition at line 52 of file FormProtectionFactory.php.