TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\FormProtection\FormProtectionFactory Class Reference
Inheritance diagram for TYPO3\CMS\Core\FormProtection\FormProtectionFactory:
t3lib_formprotection_Factory

Static Public Member Functions

static get ($className=NULL)
 
static set ($className, \TYPO3\CMS\Core\FormProtection\AbstractFormProtection $instance)
 
static purgeInstances ()
 

Static Protected Member Functions

static getClassNameByState ()
 
static isInstallToolSession ()
 
static isBackendSession ()
 
static isFrontendSession ()
 
static createAndStoreInstance ($className)
 

Static Protected Attributes

static $instances = array()
 

Private Member Functions

 __construct ()
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! 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();
$formProtection->injectInstallTool($this);
Author
Oliver Klee typo3.nosp@m.-cod.nosp@m.ing@o.nosp@m.live.nosp@m.rklee.nosp@m..de
Ernesto Baschny ernst.nosp@m.@cro.nosp@m.n-it..nosp@m.de
Helmut Hummel helmu.nosp@m.t.hu.nosp@m.mmel@.nosp@m.typo.nosp@m.3.org

Definition at line 40 of file FormProtectionFactory.php.

Constructor & Destructor Documentation

◆ __construct()

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

Private constructor to prevent instantiation.

Definition at line 52 of file FormProtectionFactory.php.

Member Function Documentation

◆ createAndStoreInstance()

static TYPO3\CMS\Core\FormProtection\FormProtectionFactory::createAndStoreInstance (   $className)
staticprotected

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

Parameters
string$className
Exceptions

Definition at line 132 of file FormProtectionFactory.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ get()

◆ getClassNameByState()

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

Returns the class name depending on TYPO3_MODE and active backend session.

Returns
string

Definition at line 82 of file FormProtectionFactory.php.

◆ isBackendSession()

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

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

Returns
boolean

Definition at line 112 of file FormProtectionFactory.php.

References $GLOBALS.

◆ isFrontendSession()

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

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

Returns
boolean

Definition at line 121 of file FormProtectionFactory.php.

References $GLOBALS, and TYPO3_MODE.

◆ isInstallToolSession()

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

Check if we are in the install tool

Returns
boolean

Definition at line 103 of file FormProtectionFactory.php.

References TYPO3_enterInstallScript.

◆ 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 165 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 (   $className,
\TYPO3\CMS\Core\FormProtection\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$className
\TYPO3\CMS\Core\FormProtection\AbstractFormProtection$instance
Returns
void

Definition at line 154 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 = array()
staticprotected

Definition at line 47 of file FormProtectionFactory.php.