PropertyMappingConfiguration
Scope: frontend
Attributes
- #[AsEventListener]
- $identifier: 'form/property-mapping-configuration'
Table of Contents
Methods
- __invoke() : void
- adjustPropertyMappingForFileUploadsAtRuntime() : void
- Adjusts property mapping configuration for file upload elements at runtime.
- registerMimeTypeValidator() : void
- Registers the MimeTypeValidator for the given file upload element based on its 'allowedMimeTypes' property.
Methods
__invoke()
public
__invoke(AfterFormStateInitializedEvent $event) : void
Parameters
- $event : AfterFormStateInitializedEvent
adjustPropertyMappingForFileUploadsAtRuntime()
Adjusts property mapping configuration for file upload elements at runtime.
protected
adjustPropertyMappingForFileUploadsAtRuntime(FormRuntime $formRuntime, RenderableInterface $renderable) : void
At this point, form definition properties (from YAML) are fully available, unlike in initializeFormElement() which runs before YAML properties are set.
This sets:
- CONFIGURATION_UPLOAD_SEED: derived from the form session identifier for creating storage sub-folders.
- CONFIGURATION_ALLOW_REMOVAL: from the element's 'allowRemoval' property to enable HMAC-signed file deletion.
It also registers the MimeTypeValidator based on the 'allowedMimeTypes' property. This must happen here (and not in FileUpload::initializeFormElement()) because the concrete form definition properties are only available at runtime.
Parameters
- $formRuntime : FormRuntime
- $renderable : RenderableInterface
registerMimeTypeValidator()
Registers the MimeTypeValidator for the given file upload element based on its 'allowedMimeTypes' property.
protected
registerMimeTypeValidator(ProcessingRule $processingRule, FileUpload $renderable) : void
The validator is only added once, even if this method is called multiple times during a request.
Parameters
- $processingRule : ProcessingRule
- $renderable : FileUpload