FormPersistenceManager
readonly class \
- Implements
- FormPersistenceManagerInterface
Concrete implementation of the FormPersistenceManagerInterface
Scope: frontend / backend
Internal
Attributes
- #[AsAlias]
- \TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface::class
- $public: true
Table of Contents
Interfaces
- FormPersistenceManagerInterface
- The form persistence manager interface
Properties
- $eventDispatcher : EventDispatcherInterface
- $filePersistenceSlot : FilePersistenceSlot
- $resourceFactory : ResourceFactory
- $runtimeCache : FrontendInterface
- $storageRepository : StorageRepository
- $typoScriptService : TypoScriptService
- $yamlSource : YamlSource
Methods
- __construct() : mixed
- delete() : void
- Delete the form representation identified by $persistenceIdentifier.
- getAccessibleExtensionFolders() : array
- Return a list of all accessible extension folders
- getAccessibleFormStorageFolders() : Folder[]
- Return a list of all accessible file mountpoints for the current backend user.
- getUniqueIdentifier() : string
- This takes a form identifier and returns a unique identifier for it.
- getUniquePersistenceIdentifier() : string
- This takes a form identifier and returns a unique persistence identifier for it.
- hasForms() : bool
- Check if any form definition is available
- hasValidFileExtension() : bool
- isAllowedPersistencePath() : bool
- Check if a persistence path or if a persistence identifier path is configured within the form setup "persistenceManager.allowedExtensionPaths" or persistenceManager.allowedFileMounts".
- listForms() : array
- List all form definitions which can be loaded through this form persistence manager.
- load() : array
- Load the array formDefinition identified by $persistenceIdentifier, let event listeners modify it, override it by TypoScript settings, and return it. Only files with the extension .yaml or .form.yaml are loaded.
- save() : void
- Save the array form representation identified by $persistenceIdentifier.
- checkForDuplicateIdentifier() : bool
- Check if an identifier is already used by a formDefinition.
- ensureValidPersistenceIdentifier() : void
- exists() : bool
- Check whether a form with the specified $persistenceIdentifier exists.
- extractMetaDataFromCouldBeFormDefinition() : array
- generateErrorsIfFormDefinitionIsInvalidOrHasInvalidFileExtension() : void
- getOrCreateFile() : File
- Returns a File object for a given $persistenceIdentifier.
- getStorageByUid() : ResourceStorage
- Returns a ResourceStorage for a given uid
- isAccessibleExtensionFolder() : bool
- isAccessibleFormStorageFolder() : bool
- isFileWithinAccessibleExtensionFolders() : bool
- isFileWithinAccessibleFormStorageFolders() : bool
- loadMetaData() : array
- looksLikeAFormDefinition() : bool
- pathIsIntendedAsExtensionPath() : bool
- pathIsIntendedAsFileMountPath() : bool
- retrieveFileByPersistenceIdentifier() : File
- retrieveYamlFilesFromExtensionFolders() : string[]
- Retrieves yaml files from extension folders for further processing.
- retrieveYamlFilesFromStorageFolders() : File[]
- Retrieves yaml files from storage folders for further processing.
- sortForms() : array
Properties
$eventDispatcher
protected
EventDispatcherInterface
$eventDispatcher
$filePersistenceSlot
protected
FilePersistenceSlot
$filePersistenceSlot
$resourceFactory
protected
ResourceFactory
$resourceFactory
$runtimeCache
protected
FrontendInterface
$runtimeCache
Attributes
- #[Autowire]
- $service: 'cache.runtime'
$storageRepository
protected
StorageRepository
$storageRepository
$typoScriptService
protected
TypoScriptService
$typoScriptService
$yamlSource
protected
YamlSource
$yamlSource
Methods
__construct()
public
__construct(YamlSource $yamlSource, StorageRepository $storageRepository, FilePersistenceSlot $filePersistenceSlot, ResourceFactory $resourceFactory, FrontendInterface $runtimeCache, EventDispatcherInterface $eventDispatcher, TypoScriptService $typoScriptService) : mixed
Parameters
- $yamlSource : YamlSource
- $storageRepository : StorageRepository
- $filePersistenceSlot : FilePersistenceSlot
- $resourceFactory : ResourceFactory
- $runtimeCache : FrontendInterface
- $eventDispatcher : EventDispatcherInterface
- $typoScriptService : TypoScriptService
delete()
Delete the form representation identified by $persistenceIdentifier.
public
delete(string $persistenceIdentifier, array $formSettings) : void
Only files with the extension .form.yaml are removed.
Parameters
- $persistenceIdentifier : string
- $formSettings : array
Tags
getAccessibleExtensionFolders()
Return a list of all accessible extension folders
public
getAccessibleExtensionFolders(array $formSettings) : array
Only registered mount points from persistenceManager.allowedExtensionPaths are listed.
Parameters
- $formSettings : array
Return values
arraygetAccessibleFormStorageFolders()
Return a list of all accessible file mountpoints for the current backend user.
public
getAccessibleFormStorageFolders(array $formSettings) : Folder[]
Only registered mount points from persistenceManager.allowedFileMounts are listed.
Parameters
- $formSettings : array
Return values
Folder[]getUniqueIdentifier()
This takes a form identifier and returns a unique identifier for it.
public
getUniqueIdentifier(array $formSettings, string $identifier) : string
If a formDefinition with the same identifier already exists a suffix is appended until the identifier is unique.
Parameters
- $formSettings : array
- $identifier : string
Tags
Return values
string —unique form identifier
getUniquePersistenceIdentifier()
This takes a form identifier and returns a unique persistence identifier for it.
public
getUniquePersistenceIdentifier(string $formIdentifier, string $savePath, array $formSettings) : string
By default, this is just similar to the identifier. But if a form with the same persistence identifier already exists a suffix is appended until the persistence identifier is unique.
Parameters
- $formIdentifier : string
-
lowerCamelCased form identifier
- $savePath : string
- $formSettings : array
Tags
Return values
string —unique form persistence identifier
hasForms()
Check if any form definition is available
public
hasForms(array $formSettings) : bool
Parameters
- $formSettings : array
Return values
boolhasValidFileExtension()
public
hasValidFileExtension(string $fileName) : bool
Parameters
- $fileName : string
Return values
boolisAllowedPersistencePath()
Check if a persistence path or if a persistence identifier path is configured within the form setup "persistenceManager.allowedExtensionPaths" or persistenceManager.allowedFileMounts".
public
isAllowedPersistencePath(string $persistencePath, array $formSettings) : bool
If the input is a persistence identifier an additional check for a valid file extension is performed.
Parameters
- $persistencePath : string
- $formSettings : array
Return values
boollistForms()
List all form definitions which can be loaded through this form persistence manager.
public
listForms(array $formSettings[, string $orderField = '' ][, SortDirection|null $orderDirection = null ]) : array
Returns an associative array with each item containing the keys 'name' (the human-readable name of the form) and 'persistenceIdentifier' (the unique identifier for the Form Persistence Manager e.g. the path to the saved form definition).
Parameters
- $formSettings : array
- $orderField : string = ''
- $orderDirection : SortDirection|null = null
Return values
array —in the format [['name' => 'Form 01', 'persistenceIdentifier' => 'path1'], [ .... ]]
load()
Load the array formDefinition identified by $persistenceIdentifier, let event listeners modify it, override it by TypoScript settings, and return it. Only files with the extension .yaml or .form.yaml are loaded.
public
load(string $persistenceIdentifier, array $formSettings, array $typoScriptSettings) : array
Parameters
- $persistenceIdentifier : string
- $formSettings : array
- $typoScriptSettings : array
-
FE TS "plugin.tx_form.settings" - Given when rendering a form as plugin using FormFrontendController or formvh:render, empty array in all BE usages. Intended to override details like labels of single forms.
Return values
arraysave()
Save the array form representation identified by $persistenceIdentifier.
public
save(string $persistenceIdentifier, array $formDefinition, array $formSettings) : void
Only files with the extension .form.yaml are saved. If the formDefinition is located within an EXT: resource, save is only allowed if the configuration path persistenceManager.allowSaveToExtensionPaths is set to true.
Parameters
- $persistenceIdentifier : string
- $formDefinition : array
- $formSettings : array
Tags
checkForDuplicateIdentifier()
Check if an identifier is already used by a formDefinition.
protected
checkForDuplicateIdentifier(array $formSettings, string $identifier) : bool
Parameters
- $formSettings : array
- $identifier : string
Return values
boolensureValidPersistenceIdentifier()
protected
ensureValidPersistenceIdentifier(string $persistenceIdentifier, array $formSettings) : void
Parameters
- $persistenceIdentifier : string
- $formSettings : array
Tags
exists()
Check whether a form with the specified $persistenceIdentifier exists.
protected
exists(string $persistenceIdentifier, array $formSettings) : bool
Parameters
- $persistenceIdentifier : string
- $formSettings : array
Return values
bool —TRUE if a form with the given $persistenceIdentifier can be loaded
extractMetaDataFromCouldBeFormDefinition()
protected
extractMetaDataFromCouldBeFormDefinition(string $maybeRawFormDefinition) : array
Parameters
- $maybeRawFormDefinition : string
Return values
arraygenerateErrorsIfFormDefinitionIsInvalidOrHasInvalidFileExtension()
protected
generateErrorsIfFormDefinitionIsInvalidOrHasInvalidFileExtension(array $formDefinition, string $persistenceIdentifier) : void
Parameters
- $formDefinition : array
- $persistenceIdentifier : string
Tags
getOrCreateFile()
Returns a File object for a given $persistenceIdentifier.
protected
getOrCreateFile(string $persistenceIdentifier) : File
If no file for this identifier exists a new object will be created.
Parameters
- $persistenceIdentifier : string
Tags
Return values
FilegetStorageByUid()
Returns a ResourceStorage for a given uid
protected
getStorageByUid(int $storageUid) : ResourceStorage
Parameters
- $storageUid : int
Tags
Return values
ResourceStorageisAccessibleExtensionFolder()
protected
isAccessibleExtensionFolder(string $folderName, array $formSettings) : bool
Parameters
- $folderName : string
- $formSettings : array
Return values
boolisAccessibleFormStorageFolder()
protected
isAccessibleFormStorageFolder(array $formSettings, string $folderName) : bool
Parameters
- $formSettings : array
- $folderName : string
Return values
boolisFileWithinAccessibleExtensionFolders()
protected
isFileWithinAccessibleExtensionFolders(string $fileName, array $formSettings) : bool
Parameters
- $fileName : string
- $formSettings : array
Return values
boolisFileWithinAccessibleFormStorageFolders()
protected
isFileWithinAccessibleFormStorageFolders(array $formSettings, string $fileName) : bool
Parameters
- $formSettings : array
- $fileName : string
Return values
boolloadMetaData()
protected
loadMetaData(string|File $persistenceIdentifier, array $formSettings) : array
Parameters
- $persistenceIdentifier : string|File
- $formSettings : array
Tags
Return values
arraylooksLikeAFormDefinition()
protected
looksLikeAFormDefinition(array $data) : bool
Parameters
- $data : array
Return values
boolpathIsIntendedAsExtensionPath()
protected
pathIsIntendedAsExtensionPath(string $path) : bool
Parameters
- $path : string
Return values
boolpathIsIntendedAsFileMountPath()
protected
pathIsIntendedAsFileMountPath(string $path) : bool
Parameters
- $path : string
Return values
boolretrieveFileByPersistenceIdentifier()
protected
retrieveFileByPersistenceIdentifier(string $persistenceIdentifier, array $formSettings) : File
Parameters
- $persistenceIdentifier : string
- $formSettings : array
Tags
Return values
FileretrieveYamlFilesFromExtensionFolders()
Retrieves yaml files from extension folders for further processing.
protected
retrieveYamlFilesFromExtensionFolders(array $formSettings) : string[]
At this time it's not determined yet, whether these files contain form data.
Parameters
- $formSettings : array
Return values
string[]retrieveYamlFilesFromStorageFolders()
Retrieves yaml files from storage folders for further processing.
protected
retrieveYamlFilesFromStorageFolders(array $formSettings) : File[]
At this time it's not determined yet, whether these files contain form data.
Parameters
- $formSettings : array
Return values
File[]sortForms()
protected
sortForms(array $forms, array $formSettings[, string $orderField = '' ][, SortDirection|null $orderDirection = null ]) : array
Parameters
- $forms : array
- $formSettings : array
- $orderField : string = ''
- $orderDirection : SortDirection|null = null