FormDefinitionConversionService

readonly class \TYPO3\CMS\Form\Domain\Configuration\FormDefinitionConversionService

Attributes

#[Autoconfigure]
$public: true

Table of Contents

Methods

__construct()  : mixed
addHmacData()  : array
Add a new value "_orig_<propertyName>" for each scalar property value within the form definition as a sibling of the property key.
extractRtePropertyPaths()  : array
Extract RTE-enabled property paths from prototype configuration.
migrateFinisherConfiguration()  : array
Migrate various finisher options
removeHmacData()  : array
Remove the "_orig_<propertyName>" values and the "_formPersistenceIdentifier" marker from the form definition.
retrieveSessionToken()  : string
Retrieve the session token for a specific form persistence identifier.
sanitizeHtml()  : array
transformRteContentForPersistence()  : array
transformRteContentForRichTextEditor()  : array
createSanitizer()  : Sanitizer
Create a sanitizer instance for the given build configuration.
generateSessionToken()  : string
Generates the random token which is used in the hash for the form tokens.
getBackendUser()  : BackendUserAuthentication
getValueByPath()  : mixed
isRteEditor()  : bool
Check if an editor configuration represents an RTE-enabled textarea.
persistSessionToken()  : void
resolveSanitizerBuildFromPreset()  : string|null
Resolve the sanitizer build name from an RTE preset configuration.
sanitizeFinisherRecursively()  : array
Recursively sanitize finisher values.
sanitizeValuesRecursively()  : array
Recursively sanitizes values in form definition.
sanitizeWithBuild()  : string
Sanitize HTML content with the specified sanitizer build.
setValueByPath()  : array
transformRteContentRecursively()  : array

Methods

addHmacData()

Add a new value "_orig_<propertyName>" for each scalar property value within the form definition as a sibling of the property key.

public addHmacData(array $formDefinition, string $formPersistenceIdentifier) : array

"orig<propertyName>" is an array which contains the property value and a hmac hash for the property value. "orig<propertyName>" will be used to validate the form definition on saving.

Parameters

$formDefinition : array
$formPersistenceIdentifier : string

Tags

see
FormDefinitionValidationService::validateFormDefinitionProperties()

Return values

array

extractRtePropertyPaths()

Extract RTE-enabled property paths from prototype configuration.

public extractRtePropertyPaths(array|PrototypeConfiguration $prototypeConfiguration) : array

Scans the form editor configuration for all form element types and finishers to find editors with enableRichtext=true and returns their property paths along with the RTE preset name, organized by element type.

Parameters

$prototypeConfiguration : array|PrototypeConfiguration

The prototype configuration

Return values

array —

Map of element types to their RTE property paths Format: [ 'Checkbox' => ['label' => 'form-label'], 'StaticText' => ['properties.text' => 'form-content'], '_finishers' => ['Confirmation' => ['options.message' => 'form-label']] ]

migrateFinisherConfiguration()

Migrate various finisher options

public migrateFinisherConfiguration(array $formDefinition) : array

Parameters

$formDefinition : array

Return values

array

removeHmacData()

Remove the "_orig_<propertyName>" values and the "_formPersistenceIdentifier" marker from the form definition.

public removeHmacData(array $formDefinition) : array

Parameters

$formDefinition : array

Return values

array

retrieveSessionToken()

Retrieve the session token for a specific form persistence identifier.

public retrieveSessionToken(string $formPersistenceIdentifier) : string

Parameters

$formPersistenceIdentifier : string

Return values

string

sanitizeHtml()

public sanitizeHtml(array $rawFormDefinitionArray[, array $rtePropertyPaths = [] ][, string $defaultBuild = 'default' ]) : array

Parameters

$rawFormDefinitionArray : array
$rtePropertyPaths : array = []
$defaultBuild : string = 'default'

Return values

array

transformRteContentForPersistence()

public transformRteContentForPersistence(array $formDefinition, array $rtePropertyPaths) : array

Parameters

$formDefinition : array
$rtePropertyPaths : array

Return values

array

transformRteContentForRichTextEditor()

public transformRteContentForRichTextEditor(array $formDefinition, array $rtePropertyPaths) : array

Parameters

$formDefinition : array
$rtePropertyPaths : array

Return values

array

createSanitizer()

Create a sanitizer instance for the given build configuration.

protected createSanitizer(string $build) : Sanitizer

Supports both preset names (e.g., 'default') and class names implementing BuilderInterface.

Parameters

$build : string

The sanitizer build name or class name

Return values

Sanitizer —

The sanitizer instance

generateSessionToken()

Generates the random token which is used in the hash for the form tokens.

protected generateSessionToken() : string

Return values

string

getValueByPath()

protected getValueByPath(array $array, string $path) : mixed

Parameters

$array : array
$path : string

isRteEditor()

Check if an editor configuration represents an RTE-enabled textarea.

protected isRteEditor(array $editor) : bool

Parameters

$editor : array

Return values

bool

persistSessionToken()

protected persistSessionToken(string $sessionToken, string $formPersistenceIdentifier) : void

Parameters

$sessionToken : string
$formPersistenceIdentifier : string

resolveSanitizerBuildFromPreset()

Resolve the sanitizer build name from an RTE preset configuration.

protected resolveSanitizerBuildFromPreset(string $presetName) : string|null

Parameters

$presetName : string

The RTE preset name (e.g., 'form-label', 'form-content')

Return values

string|null —

The sanitizer build name, or null if not configured

sanitizeFinisherRecursively()

Recursively sanitize finisher values.

protected sanitizeFinisherRecursively(array $finisher, array $rteFields[, string $defaultBuild = 'default' ][, string $currentPath = '' ]) : array

Parameters

$finisher : array

The finisher configuration

$rteFields : array

Map of RTE field paths to their preset names

$defaultBuild : string = 'default'

Default sanitizer build name

$currentPath : string = ''

Current property path

Return values

array

sanitizeValuesRecursively()

Recursively sanitizes values in form definition.

protected sanitizeValuesRecursively(array $array[, array $rtePropertyPaths = [] ][, string $defaultBuild = 'default' ][, string|null $currentElementType = null ][, string $currentPath = '' ]) : array

For RTE-enabled fields: Uses HtmlSanitizer with the preset configured in the RTE configuration For all other string fields: Uses strip_tags to remove ALL HTML

Parameters

$array : array

The array to sanitize

$rtePropertyPaths : array = []

Map of element types to their RTE property paths with preset names

$defaultBuild : string = 'default'

Default sanitizer build name for RTE fields without specific preset

$currentElementType : string|null = null

The current element type being processed

$currentPath : string = ''

The current property path being processed

Return values

array

sanitizeWithBuild()

Sanitize HTML content with the specified sanitizer build.

protected sanitizeWithBuild(string $content, string $build) : string

Parameters

$content : string

The HTML content to sanitize

$build : string

The sanitizer build name or class name

Return values

string —

The sanitized content

setValueByPath()

protected setValueByPath(array $array, string $path, mixed $value) : array

Parameters

$array : array
$path : string
$value : mixed

Return values

array

transformRteContentRecursively()

protected transformRteContentRecursively(array $formDefinition, array $rtePropertyPaths, RichTextConfigurationService $richTextConfigurationService[, string $direction = 'persistence' ]) : array

Parameters

$formDefinition : array
$rtePropertyPaths : array
$richTextConfigurationService : RichTextConfigurationService
$direction : string = 'persistence'

Return values

array
On this page