ConfigurationService

class \TYPO3\CMS\Form\Domain\Configuration\ConfigurationService

Helper for configuration settings Scope: frontend / backend

Tags

todo:

Get rid of ConfigurationManagerInterface by handing over $formSettings to methods instead to make the indirect dependency to Request explicit in consuming classes.

todo:

Declare readonly when ConfigurationService is no longer injected lazy, or wait for PHP 8.3 minimum for symfony to allow both lazy and readonly dependencies.

Attributes

#[Autoconfigure]
$public: true

Table of Contents

Properties

$assetsCache  : FrontendInterface
$extbaseConfigurationManager  : ConfigurationManagerInterface
$extFormConfigurationManager  : ConfigurationManagerInterface
$runtimeCache  : FrontendInterface
$translationService  : TranslationService

Methods

__construct()  : mixed
formElementPropertyHasLimitedAllowedValuesDefinedWithinFormEditorSetup()  : bool
If a form element editor has a property called "selectOptions" (e.g. editors with templateName "Inspector-SingleSelectEditor" or "Inspector-MultiSelectEditor") then only the defined values within the selectOptions are allowed to be written by the form editor.
getAllBackendTranslationsForTranslationKey()  : array
getAllBackendTranslationsForTranslationKeys()  : array
getAllowedValuesForFormElementPropertyFromFormEditorSetup()  : array
Get the "selectOptions" value for a form element property from the form setup.
getAllowedValuesForPropertyCollectionPropertyFromFormEditorSetup()  : array
Get the "selectOptions" value for a form elements finisher|validator property from the form setup.
getFormElementPredefinedDefaultValueFromFormEditorSetup()  : mixed
Get the "predefinedDefaults" value for a form element property from the form setup.
getPropertyCollectionPredefinedDefaultValueFromFormEditorSetup()  : mixed
Get the "predefinedDefaults" value for a form elements finisher|validator property from the form setup.
getPrototypeConfiguration()  : array
Get the prototype configuration
getSelectablePrototypeNamesDefinedInFormEditorSetup()  : array
Return all prototype names which are defined within "formManager.selectablePrototypesConfiguration.*.identifier"
isFormElementPropertyDefinedInFormEditorSetup()  : bool
Check if a form element property is defined in the form setup.
isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup()  : bool
Check if a form element property is defined in "predefinedDefaults" in the form setup.
isFormElementTypeCreatableByFormEditor()  : bool
Check if the form element is creatable through the form editor.
isFormElementTypeDefinedInFormSetup()  : bool
Check if the form elements type is defined within the form setup.
isPropertyCollectionElementIdentifierCreatableByFormEditor()  : bool
Check if the form elements finisher|validator is creatable through the form editor.
isPropertyCollectionPropertyDefinedInFormEditorSetup()  : bool
Check if a form elements finisher|validator property is defined in the form setup.
isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup()  : bool
Check if a form elements finisher|validator property is defined in "predefinedDefaults" in the form setup.
propertyCollectionPropertyHasLimitedAllowedValuesDefinedWithinFormEditorSetup()  : bool
If a form elements finisher|validator editor has a property called "selectOptions" (e.g. editors with templateName "Inspector-SingleSelectEditor" or "Inspector-MultiSelectEditor") then only the defined values within the selectOptions are allowed to be written by the form editor.
addAdditionalPropertyPathsFromHook()  : array
buildFormDefinitionValidationConfigurationFromFormEditorSetup()  : array
Collect all the form editor configurations which are needed to check if a form definition property can be written or not.
executeBuildFormDefinitionValidationConfigurationHooks()  : array
If you use a custom form editor "inspector editor" implementation which does not define the writable property paths by one of the described inspector editor properties (e.g "propertyPath") within the form setup, you must provide the writable property paths with a hook.
getBasePropertyPathFromMultiValueFormElementProperty()  : string
getBasePropertyPathFromMultiValuePropertyCollectionElement()  : string
getCacheEntry()  : mixed
getFormSettings()  : array
isPropertyDefinedInFormEditorSetup()  : bool
setCacheEntry()  : void
translatePredefinedDefaults()  : array
translateSelectOptions()  : array
translateValues()  : array

Properties

Methods

__construct()

public __construct(ConfigurationManagerInterface $extbaseConfigurationManager, ConfigurationManagerInterface $extFormConfigurationManager, TranslationService $translationService, FrontendInterface $assetsCache, FrontendInterface $runtimeCache) : mixed

Parameters

$extbaseConfigurationManager : ConfigurationManagerInterface
$extFormConfigurationManager : ConfigurationManagerInterface
$translationService : TranslationService
$assetsCache : FrontendInterface
$runtimeCache : FrontendInterface

formElementPropertyHasLimitedAllowedValuesDefinedWithinFormEditorSetup()

If a form element editor has a property called "selectOptions" (e.g. editors with templateName "Inspector-SingleSelectEditor" or "Inspector-MultiSelectEditor") then only the defined values within the selectOptions are allowed to be written by the form editor.

public formElementPropertyHasLimitedAllowedValuesDefinedWithinFormEditorSetup(ValidationDto $dto) : bool

Parameters

$dto : ValidationDto

Return values

bool

getAllBackendTranslationsForTranslationKey()

public getAllBackendTranslationsForTranslationKey(string $key, string $prototypeName) : array

Parameters

$key : string
$prototypeName : string

Return values

array

getAllBackendTranslationsForTranslationKeys()

public getAllBackendTranslationsForTranslationKeys(array $keys, string $prototypeName) : array

Parameters

$keys : array
$prototypeName : string

Return values

array

getAllowedValuesForFormElementPropertyFromFormEditorSetup()

Get the "selectOptions" value for a form element property from the form setup.

public getAllowedValuesForFormElementPropertyFromFormEditorSetup(ValidationDto $dto[, bool $translated = true ]) : array

Parameters

$dto : ValidationDto
$translated : bool = true

Tags

throws
PropertyException

Return values

array

getAllowedValuesForPropertyCollectionPropertyFromFormEditorSetup()

Get the "selectOptions" value for a form elements finisher|validator property from the form setup.

public getAllowedValuesForPropertyCollectionPropertyFromFormEditorSetup(ValidationDto $dto[, bool $translated = true ]) : array

Parameters

$dto : ValidationDto
$translated : bool = true

Tags

throws
PropertyException

Return values

array

getFormElementPredefinedDefaultValueFromFormEditorSetup()

Get the "predefinedDefaults" value for a form element property from the form setup.

public getFormElementPredefinedDefaultValueFromFormEditorSetup(ValidationDto $dto[, bool $translated = true ]) : mixed

A form element default property is defined within the following form editor properties:

  • formElementsDefinition.<formElementType>.formEditor.predefinedDefaults.<propertyPath> = "default value"

Parameters

$dto : ValidationDto
$translated : bool = true

Tags

throws
PropertyException

getPropertyCollectionPredefinedDefaultValueFromFormEditorSetup()

Get the "predefinedDefaults" value for a form elements finisher|validator property from the form setup.

public getPropertyCollectionPredefinedDefaultValueFromFormEditorSetup(ValidationDto $dto[, bool $translated = true ]) : mixed

A form elements finisher|validator default property is defined within the following form editor properties:

  • <validatorsDefinition|finishersDefinition>..formEditor.predefinedDefaults.<propertyPath> = "default value"

Parameters

$dto : ValidationDto
$translated : bool = true

Tags

throws
PropertyException

getPrototypeConfiguration()

Get the prototype configuration

public getPrototypeConfiguration(string $prototypeName) : array

Parameters

$prototypeName : string

name of the prototype to get the configuration for

Tags

throws
PrototypeNotFoundException

if prototype with the name $prototypeName was not found

Return values

array —

the prototype configuration

getSelectablePrototypeNamesDefinedInFormEditorSetup()

Return all prototype names which are defined within "formManager.selectablePrototypesConfiguration.*.identifier"

public getSelectablePrototypeNamesDefinedInFormEditorSetup() : array

Return values

array

isFormElementPropertyDefinedInFormEditorSetup()

Check if a form element property is defined in the form setup.

public isFormElementPropertyDefinedInFormEditorSetup(ValidationDto $dto) : bool

If a form element property is defined in the form setup then it means that the form element property can be written by the form editor. A form element property can be written if the property path is defined within the following form editor properties:

  • formElementsDefinition.<formElementType>.formEditor.editors..propertyPath
  • formElementsDefinition.<formElementType>.formEditor.editors..*.propertyPath
  • formElementsDefinition.<formElementType>.formEditor.editors..additionalElementPropertyPaths
  • formElementsDefinition.<formElementType>.formEditor.propertyCollections.<finishers|validators>..editors..additionalElementPropertyPaths If a form editor property "templateName" is "Inspector-PropertyGridEditor" or "Inspector-MultiSelectEditor" or "Inspector-ValidationErrorMessageEditor" it means that the form editor property "propertyPath" is interpreted as a so called "multiValueProperty". A "multiValueProperty" can contain any subproperties relative to the value from "propertyPath" which are valid. If "formElementsDefinition.<formElementType>.formEditor.editors..templateName = Inspector-PropertyGridEditor" and "formElementsDefinition.<formElementType>.formEditor.editors..propertyPath = options.xxx" then (for example) "options.xxx.yyy" is a valid property path to write. If you use a custom form editor "inspector editor" implementation which does not define the writable property paths by one of the above described inspector editor properties (e.g "propertyPath") within the form setup, you must provide the writable property paths with a hook.

Parameters

$dto : ValidationDto

Tags

see
executeBuildFormDefinitionValidationConfigurationHooks()

Return values

bool

isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup()

Check if a form element property is defined in "predefinedDefaults" in the form setup.

public isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup(ValidationDto $dto) : bool

If a form element property is defined in the "predefinedDefaults" in the form setup then it means that the form element property can be written by the form editor. A form element default property is defined within the following form editor properties:

  • formElementsDefinition.<formElementType>.formEditor.predefinedDefaults.<propertyPath> = "default value"

Parameters

$dto : ValidationDto

Return values

bool

isFormElementTypeCreatableByFormEditor()

Check if the form element is creatable through the form editor.

public isFormElementTypeCreatableByFormEditor(ValidationDto $dto) : bool

A form element is creatable if the following properties are set:

  • formElementsDefinition.<formElementType>.formEditor.group
  • formElementsDefinition.<formElementType>.formEditor.groupSorting And the value from "formElementsDefinition.<formElementType>.formEditor.group" is one of the keys within "formEditor.formElementGroups"

Parameters

$dto : ValidationDto

Return values

bool

isFormElementTypeDefinedInFormSetup()

Check if the form elements type is defined within the form setup.

public isFormElementTypeDefinedInFormSetup(ValidationDto $dto) : bool

Parameters

$dto : ValidationDto

Return values

bool

isPropertyCollectionElementIdentifierCreatableByFormEditor()

Check if the form elements finisher|validator is creatable through the form editor.

public isPropertyCollectionElementIdentifierCreatableByFormEditor(ValidationDto $dto) : bool

A form elements finisher|validator is creatable if the following conditions are true: "formElementsDefinition.<formElementType>.formEditor.editors..templateName = Inspector-FinishersEditor" or "formElementsDefinition.<formElementType>.formEditor.editors..templateName = Inspector-ValidatorsEditor" and "formElementsDefinition.<formElementType>.formEditor.editors..selectOptions..value = <finisherIdentifier|validatorIdentifier>"

Parameters

$dto : ValidationDto

Return values

bool

isPropertyCollectionPropertyDefinedInFormEditorSetup()

Check if a form elements finisher|validator property is defined in the form setup.

public isPropertyCollectionPropertyDefinedInFormEditorSetup(ValidationDto $dto) : bool

If a form elements finisher|validator property is defined in the form setup then it means that the form elements finisher|validator property can be written by the form editor. A form elements finisher|validator property can be written if the property path is defined within the following form editor properties:

  • formElementsDefinition.<formElementType>.formEditor.propertyCollections.<finishers|validators>..editors..propertyPath
  • formElementsDefinition.<formElementType>.formEditor.propertyCollections.<finishers|validators>..editors..*.propertyPath If a form elements finisher|validator property "templateName" is "Inspector-PropertyGridEditor" or "Inspector-MultiSelectEditor" or "Inspector-ValidationErrorMessageEditor" it means that the form editor property "propertyPath" is interpreted as a so called "multiValueProperty". A "multiValueProperty" can contain any subproperties relative to the value from "propertyPath" which are valid. If "formElementsDefinition.<formElementType>.formEditor.propertyCollections.<finishers|validators>..editors..templateName = Inspector-PropertyGridEditor" and "formElementsDefinition.<formElementType>.formEditor.propertyCollections.<finishers|validators>..editors..propertyPath = options.xxx" that (for example) "options.xxx.yyy" is a valid property path to write. If you use a custom form editor "inspector editor" implementation which not defines the writable property paths by one of the above described inspector editor properties (e.g "propertyPath") within the form setup, you must provide the writable property paths with a hook.

Parameters

$dto : ValidationDto

Tags

see
executeBuildFormDefinitionValidationConfigurationHooks()

Return values

bool

isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup()

Check if a form elements finisher|validator property is defined in "predefinedDefaults" in the form setup.

public isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup(ValidationDto $dto) : bool

If a form elements finisher|validator property is defined in "predefinedDefaults" in the form setup then it means that the form elements finisher|validator property can be written by the form editor. A form elements finisher|validator default property is defined within the following form editor properties:

  • <validatorsDefinition|finishersDefinition>..formEditor.predefinedDefaults.<propertyPath> = "default value"

Parameters

$dto : ValidationDto

Return values

bool

propertyCollectionPropertyHasLimitedAllowedValuesDefinedWithinFormEditorSetup()

If a form elements finisher|validator editor has a property called "selectOptions" (e.g. editors with templateName "Inspector-SingleSelectEditor" or "Inspector-MultiSelectEditor") then only the defined values within the selectOptions are allowed to be written by the form editor.

public propertyCollectionPropertyHasLimitedAllowedValuesDefinedWithinFormEditorSetup(ValidationDto $dto) : bool

Parameters

$dto : ValidationDto

Return values

bool

addAdditionalPropertyPathsFromHook()

protected addAdditionalPropertyPathsFromHook(string $hookClassName, string $prototypeName, array $propertyPathsFromHook, array $configuration) : array

Parameters

$hookClassName : string
$prototypeName : string
$propertyPathsFromHook : array
$configuration : array

Tags

throws
PropertyException

Return values

array

buildFormDefinitionValidationConfigurationFromFormEditorSetup()

Collect all the form editor configurations which are needed to check if a form definition property can be written or not.

protected buildFormDefinitionValidationConfigurationFromFormEditorSetup(string $prototypeName) : array

Parameters

$prototypeName : string

Return values

array

executeBuildFormDefinitionValidationConfigurationHooks()

If you use a custom form editor "inspector editor" implementation which does not define the writable property paths by one of the described inspector editor properties (e.g "propertyPath") within the form setup, you must provide the writable property paths with a hook.

protected executeBuildFormDefinitionValidationConfigurationHooks(string $prototypeName, array $configuration) : array

Parameters

$prototypeName : string
$configuration : array

Tags

see
isFormElementPropertyDefinedInFormEditorSetup()
see
isPropertyCollectionPropertyDefinedInFormEditorSetup()

Connect to the hook: $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['buildFormDefinitionValidationConfiguration'][] = \Vendor\YourNamespace\YourClass::class; Use the hook: public function addAdditionalPropertyPaths(\TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\ValidationDto $validationDto): array { $textValidationDto = $validationDto->withFormElementType('Text'); $textValidatorsValidationDto = $textValidationDto->withPropertyCollectionName('validators'); $dateValidationDto = $validationDto->withFormElementType('Date'); $propertyPaths = [ $textValidationDto->withPropertyPath('properties.my.custom.property'), $textValidationDto->withPropertyPath('properties.my.other.custom.property'), $textValidatorsValidationDto->withPropertyCollectionElementIdentifier('StringLength')->withPropertyPath('options.custom.property'), $textValidatorsValidationDto->withPropertyCollectionElementIdentifier('CustomValidator')->withPropertyPath('options.other.custom.property'), $dateValidationDto->withPropertyPath('properties.custom.property'), // .. ]; return $propertyPaths; }

throws
PropertyException

Return values

array

getBasePropertyPathFromMultiValueFormElementProperty()

protected getBasePropertyPathFromMultiValueFormElementProperty(ValidationDto $dto) : string

Parameters

$dto : ValidationDto

Return values

string

getBasePropertyPathFromMultiValuePropertyCollectionElement()

protected getBasePropertyPathFromMultiValuePropertyCollectionElement(ValidationDto $dto) : string

Parameters

$dto : ValidationDto

Return values

string

getCacheEntry()

protected getCacheEntry(string $cacheKey) : mixed

Parameters

$cacheKey : string

getFormSettings()

protected getFormSettings() : array

Return values

array

isPropertyDefinedInFormEditorSetup()

protected isPropertyDefinedInFormEditorSetup(string $propertyPath, array $subConfig) : bool

Parameters

$propertyPath : string
$subConfig : array

Return values

bool

setCacheEntry()

protected setCacheEntry(string $cacheKey, mixed $value) : void

Parameters

$cacheKey : string
$value : mixed

translatePredefinedDefaults()

protected translatePredefinedDefaults(array $prototypeConfiguration, array $formElements) : array

Parameters

$prototypeConfiguration : array
$formElements : array

Return values

array

translateSelectOptions()

protected translateSelectOptions(array $prototypeConfiguration, array $formElements) : array

Parameters

$prototypeConfiguration : array
$formElements : array

Return values

array

translateValues()

protected translateValues(array $prototypeConfiguration, array $configuration) : array

Parameters

$prototypeConfiguration : array
$configuration : array

Return values

array
On this page