3 namespace Drupal\Core\Config;
6 * Defines an interface for configuration storage.
8 * Classes implementing this interface allow reading and writing configuration
9 * data from and to the storage.
11 interface StorageInterface {
14 * The default collection name.
16 const DEFAULT_COLLECTION = '';
19 * Returns whether a configuration object exists.
22 * The name of a configuration object to test.
25 * TRUE if the configuration object exists, FALSE otherwise.
27 public function exists($name);
30 * Reads configuration data from the storage.
33 * The name of a configuration object to load.
36 * The configuration data stored for the configuration object name. If no
37 * configuration data exists for the given name, FALSE is returned.
39 public function read($name);
42 * Reads configuration data from the storage.
45 * List of names of the configuration objects to load.
48 * A list of the configuration data stored for the configuration object name
49 * that could be loaded for the passed list of names.
51 public function readMultiple(array $names);
54 * Writes configuration data to the storage.
57 * The name of a configuration object to save.
59 * The configuration data to write.
62 * TRUE on success, FALSE in case of an error.
64 * @throws \Drupal\Core\Config\StorageException
65 * If the back-end storage does not exist and cannot be created.
67 public function write($name, array $data);
70 * Deletes a configuration object from the storage.
73 * The name of a configuration object to delete.
76 * TRUE on success, FALSE otherwise.
78 public function delete($name);
81 * Renames a configuration object in the storage.
84 * The name of a configuration object to rename.
85 * @param string $new_name
86 * The new name of a configuration object.
89 * TRUE on success, FALSE otherwise.
91 public function rename($name, $new_name);
94 * Encodes configuration data into the storage-specific format.
96 * This is a publicly accessible static method to allow for alternative
97 * usages in data conversion scripts and also tests.
100 * The configuration data to encode.
103 * The encoded configuration data.
105 public function encode($data);
108 * Decodes configuration data from the storage-specific format.
110 * This is a publicly accessible static method to allow for alternative
111 * usages in data conversion scripts and also tests.
114 * The raw configuration data string to decode.
117 * The decoded configuration data as an associative array.
119 public function decode($raw);
122 * Gets configuration object names starting with a given prefix.
124 * Given the following configuration objects:
125 * - node.type.article
128 * Passing the prefix 'node.type.' will return an array containing the above
131 * @param string $prefix
132 * (optional) The prefix to search for. If omitted, all configuration object
133 * names that exist are returned.
136 * An array containing matching configuration object names.
138 public function listAll($prefix = '');
141 * Deletes configuration objects whose names start with a given prefix.
143 * Given the following configuration object names:
144 * - node.type.article
147 * Passing the prefix 'node.type.' will delete the above configuration
150 * @param string $prefix
151 * (optional) The prefix to search for. If omitted, all configuration
152 * objects that exist will be deleted.
155 * TRUE on success, FALSE otherwise.
157 public function deleteAll($prefix = '');
160 * Creates a collection on the storage.
162 * A configuration storage can contain multiple sets of configuration objects
163 * in partitioned collections. The collection name identifies the current
166 * Implementations of this method must provide a new instance to avoid side
167 * effects caused by the fact that Config objects have their storage injected.
169 * @param string $collection
170 * The collection name. Valid collection names conform to the following
171 * regex [a-zA-Z_.]. A storage does not need to have a collection set.
172 * However, if a collection is set, then storage should use it to store
173 * configuration in a way that allows retrieval of configuration for a
174 * particular collection.
176 * @return \Drupal\Core\Config\StorageInterface
177 * A new instance of the storage backend with the collection set.
179 public function createCollection($collection);
182 * Gets the existing collections.
184 * A configuration storage can contain multiple sets of configuration objects
185 * in partitioned collections. The collection key name identifies the current
189 * An array of existing collection names.
191 public function getAllCollectionNames();
194 * Gets the name of the current collection the storage is using.
197 * The current collection name.
199 public function getCollectionName();