FormProtectionFactory
This class creates and manages instances of the various form protection classes.
Previously this class provides only provided static methods and could not be instantiated.
Since TYPO3 v12, this class can and should be used as a factory to be injected into other controllers or middlewares, to handle FormProtections for HTTP Requests.
Table of Contents
Properties
- $flashMessageService : FlashMessageService
- $languageServiceFactory : LanguageServiceFactory
- $registry : Registry
- $runtimeCache : FrontendInterface
Methods
- __construct() : mixed
- createForType() : AbstractFormProtection
- Method should be used whenever you do not have direct access to the request object.
- createFromRequest() : AbstractFormProtection
- Detect the right FormProtection implementation based on the request.
- createInstance() : AbstractFormProtection
- Creates an instance for the requested class $className and stores it internally.
- determineTypeFromRequest() : string
- Detects the type of FormProtection which should be instantiated, based on the request.
- getClassNameAndConstructorArguments() : array<string|int, mixed>
- This is the equivalent to getClassNameAndConstructorArgumentsByType() but non-static.
- getIdentifierForType() : string
- Conveniant method to create a deterministic cache identifier.
- getMessageClosure() : Closure
- 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
$flashMessageService read-only
protected
FlashMessageService
$flashMessageService
$languageServiceFactory read-only
protected
LanguageServiceFactory
$languageServiceFactory
$registry read-only
protected
Registry
$registry
$runtimeCache read-only
protected
FrontendInterface
$runtimeCache
Methods
__construct()
public
__construct(FlashMessageService $flashMessageService, LanguageServiceFactory $languageServiceFactory, Registry $registry, FrontendInterface $runtimeCache) : mixed
Parameters
- $flashMessageService : FlashMessageService
- $languageServiceFactory : LanguageServiceFactory
- $registry : Registry
- $runtimeCache : FrontendInterface
createForType()
Method should be used whenever you do not have direct access to the request object.
public
createForType(string $type) : AbstractFormProtection
It is however recommended to use createFromRequest() whenever you have a PSR-7 request object available.
Parameters
- $type : string
Return values
AbstractFormProtectioncreateFromRequest()
Detect the right FormProtection implementation based on the request.
public
createFromRequest(ServerRequestInterface $request) : AbstractFormProtection
Parameters
- $request : ServerRequestInterface
Return values
AbstractFormProtectioncreateInstance()
Creates an instance for the requested class $className and stores it internally.
protected
createInstance(class-string $className, array<int, mixed> ...$constructorArguments) : AbstractFormProtection
Parameters
- $className : class-string
- $constructorArguments : array<int, mixed>
Tags
Return values
AbstractFormProtectiondetermineTypeFromRequest()
Detects the type of FormProtection which should be instantiated, based on the request.
protected
determineTypeFromRequest(ServerRequestInterface $request) : string
Parameters
- $request : ServerRequestInterface
Return values
stringgetClassNameAndConstructorArguments()
This is the equivalent to getClassNameAndConstructorArgumentsByType() but non-static.
protected
getClassNameAndConstructorArguments(string $type, ServerRequestInterface|null $request) : array<string|int, mixed>
It also does not handle "default" or class names, but is based on types previously resolved by the request. See determineTypeFromRequest()
Parameters
- $type : string
-
Valid types: installtool, frontend, backend.
- $request : ServerRequestInterface|null
Return values
array<string|int, mixed> —Array of arguments
getIdentifierForType()
Conveniant method to create a deterministic cache identifier.
protected
getIdentifierForType(string $type) : string
Parameters
- $type : string
Return values
stringgetMessageClosure()
protected
getMessageClosure(LanguageService $languageService, FlashMessageQueue $messageQueue, bool $isAjaxCall) : Closure
Parameters
- $languageService : LanguageService
- $messageQueue : FlashMessageQueue
- $isAjaxCall : bool
Return values
ClosureisBackendSession()
Checks if a user is logged in and the session is active.
protected
isBackendSession() : bool
Return values
boolisFrontendSession()
Checks if a frontend user is logged in and the session is active.
protected
isFrontendSession(ServerRequestInterface $request) : bool
Parameters
- $request : ServerRequestInterface
Return values
boolisInstallToolSession()
Check if we are in the install tool
protected
isInstallToolSession(ServerRequestInterface $request) : bool
Parameters
- $request : ServerRequestInterface