FormDefinitionConversionService
Attributes
- #[Autoconfigure]
- $public: true
Table of Contents
Methods
- __construct() : mixed
- addHmacData() : array<string|int, mixed>
- Add a new value "_orig_<propertyName>" for each scalar property value within the form definition as a sibling of the property key.
- extractRtePropertyPaths() : array<string|int, mixed>
- Extract RTE-enabled property paths from prototype configuration.
- migrateFinisherConfiguration() : array<string|int, mixed>
- Migrate various finisher options
- removeHmacData() : array<string|int, mixed>
- 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<string|int, mixed>
- transformRteContentForPersistence() : array<string|int, mixed>
- transformRteContentForRichTextEditor() : array<string|int, mixed>
- 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<string|int, mixed>
- Recursively sanitize finisher values.
- sanitizeValuesRecursively() : array<string|int, mixed>
- Recursively sanitizes values in form definition.
- sanitizeWithBuild() : string
- Sanitize HTML content with the specified sanitizer build.
- setValueByPath() : array<string|int, mixed>
- transformRteContentRecursively() : array<string|int, mixed>
Methods
__construct()
public
__construct(RichTextConfigurationService $richTextConfigurationService) : mixed
Parameters
- $richTextConfigurationService : RichTextConfigurationService
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<string|int, mixed> $formDefinition, string $formPersistenceIdentifier) : array<string|int, mixed>
"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<string|int, mixed>
- $formPersistenceIdentifier : string
Tags
Return values
array<string|int, mixed>extractRtePropertyPaths()
Extract RTE-enabled property paths from prototype configuration.
public
extractRtePropertyPaths(array<string|int, mixed> $prototypeConfiguration) : array<string|int, mixed>
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<string|int, mixed>
-
The prototype configuration array
Return values
array<string|int, mixed> —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<string|int, mixed> $formDefinition) : array<string|int, mixed>
Parameters
- $formDefinition : array<string|int, mixed>
Return values
array<string|int, mixed>removeHmacData()
Remove the "_orig_<propertyName>" values and the "_formPersistenceIdentifier" marker from the form definition.
public
removeHmacData(array<string|int, mixed> $formDefinition) : array<string|int, mixed>
Parameters
- $formDefinition : array<string|int, mixed>
Return values
array<string|int, mixed>retrieveSessionToken()
Retrieve the session token for a specific form persistence identifier.
public
retrieveSessionToken(string $formPersistenceIdentifier) : string
Parameters
- $formPersistenceIdentifier : string
Return values
stringsanitizeHtml()
public
sanitizeHtml(array<string|int, mixed> $rawFormDefinitionArray[, array<string|int, mixed> $rtePropertyPaths = [] ][, string $defaultBuild = 'default' ]) : array<string|int, mixed>
Parameters
- $rawFormDefinitionArray : array<string|int, mixed>
- $rtePropertyPaths : array<string|int, mixed> = []
- $defaultBuild : string = 'default'
Return values
array<string|int, mixed>transformRteContentForPersistence()
public
transformRteContentForPersistence(array<string|int, mixed> $formDefinition, array<string|int, mixed> $rtePropertyPaths) : array<string|int, mixed>
Parameters
- $formDefinition : array<string|int, mixed>
- $rtePropertyPaths : array<string|int, mixed>
Return values
array<string|int, mixed>transformRteContentForRichTextEditor()
public
transformRteContentForRichTextEditor(array<string|int, mixed> $formDefinition, array<string|int, mixed> $rtePropertyPaths) : array<string|int, mixed>
Parameters
- $formDefinition : array<string|int, mixed>
- $rtePropertyPaths : array<string|int, mixed>
Return values
array<string|int, mixed>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
stringgetBackendUser()
protected
getBackendUser() : BackendUserAuthentication
Return values
BackendUserAuthenticationgetValueByPath()
protected
getValueByPath(array<string|int, mixed> $array, string $path) : mixed
Parameters
- $array : array<string|int, mixed>
- $path : string
isRteEditor()
Check if an editor configuration represents an RTE-enabled textarea.
protected
isRteEditor(array<string|int, mixed> $editor) : bool
Parameters
- $editor : array<string|int, mixed>
Return values
boolpersistSessionToken()
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<string|int, mixed> $finisher, array<string|int, mixed> $rteFields[, string $defaultBuild = 'default' ][, string $currentPath = '' ]) : array<string|int, mixed>
Parameters
- $finisher : array<string|int, mixed>
-
The finisher configuration
- $rteFields : array<string|int, mixed>
-
Map of RTE field paths to their preset names
- $defaultBuild : string = 'default'
-
Default sanitizer build name
- $currentPath : string = ''
-
Current property path
Return values
array<string|int, mixed>sanitizeValuesRecursively()
Recursively sanitizes values in form definition.
protected
sanitizeValuesRecursively(array<string|int, mixed> $array[, array<string|int, mixed> $rtePropertyPaths = [] ][, string $defaultBuild = 'default' ][, string|null $currentElementType = null ][, string $currentPath = '' ]) : array<string|int, mixed>
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<string|int, mixed>
-
The array to sanitize
- $rtePropertyPaths : array<string|int, mixed> = []
-
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<string|int, mixed>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<string|int, mixed> $array, string $path, mixed $value) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $path : string
- $value : mixed
Return values
array<string|int, mixed>transformRteContentRecursively()
protected
transformRteContentRecursively(array<string|int, mixed> $formDefinition, array<string|int, mixed> $rtePropertyPaths, RichTextConfigurationService $richTextConfigurationService[, string $direction = 'persistence' ]) : array<string|int, mixed>
Parameters
- $formDefinition : array<string|int, mixed>
- $rtePropertyPaths : array<string|int, mixed>
- $richTextConfigurationService : RichTextConfigurationService
- $direction : string = 'persistence'