1<?php
2declare(strict_types = 1);
3namespace TYPO3\CMS\Form\Mvc\Persistence;
4
5/*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It originated from the Neos.Form package (www.neos.io)
9 *
10 * It is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, either version 2
12 * of the License, or any later version.
13 *
14 * For the full copyright and license information, please read the
15 * LICENSE.txt file that was distributed with this source code.
16 *
17 * The TYPO3 project - inspiring people to share!
18 */
19
20use TYPO3\CMS\Core\Resource\Folder;
21
22/**
23 * The form persistence manager interface
24 *
25 * Scope: frontend / backend
26 */
27interface FormPersistenceManagerInterface
28{
29
30    /**
31     * Load the array form representation identified by $persistenceIdentifier, and return it
32     *
33     * @param string $persistenceIdentifier
34     * @return array
35     */
36    public function load(string $persistenceIdentifier): array;
37
38    /**
39     * Save the array form representation identified by $persistenceIdentifier
40     *
41     * @param string $persistenceIdentifier
42     * @param array $formDefinition
43     */
44    public function save(string $persistenceIdentifier, array $formDefinition);
45
46    /**
47     * Check whether a form with the specified $persistenceIdentifier exists
48     *
49     * @param string $persistenceIdentifier
50     * @return bool TRUE if a form with the given $persistenceIdentifier can be loaded, otherwise FALSE
51     */
52    public function exists(string $persistenceIdentifier): bool;
53
54    /**
55     * Delete the form representation identified by $persistenceIdentifier
56     *
57     * @param string $persistenceIdentifier
58     */
59    public function delete(string $persistenceIdentifier);
60
61    /**
62     * List all form definitions which can be loaded through this form persistence
63     * manager.
64     *
65     * Returns an associative array with each item containing the keys 'name' (the human-readable name of the form)
66     * and 'persistenceIdentifier' (the unique identifier for the Form Persistence Manager e.g. the path to the saved form definition).
67     *
68     * @return array in the format [['name' => 'Form 01', 'persistenceIdentifier' => 'path1'], [ .... ]]
69     */
70    public function listForms(): array;
71
72    /**
73     * Return a list of all accessible file mount points
74     *
75     * @return Folder[]
76     */
77    public function getAccessibleFormStorageFolders(): array;
78
79    /**
80     * Return a list of all accessible extension folders
81     *
82     * @return array
83     */
84    public function getAccessibleExtensionFolders(): array;
85
86    /**
87     * This takes a form identifier and returns a unique persistence identifier for it.
88     *
89     * @param string $formIdentifier
90     * @param string $savePath
91     * @return string
92     */
93    public function getUniquePersistenceIdentifier(string $formIdentifier, string $savePath): string;
94
95    /**
96     * Check if a identifier is already used by a formDefintion.
97     *
98     * @param string $identifier
99     * @return bool
100     */
101    public function checkForDuplicateIdentifier(string $identifier): bool;
102}
103