FileStorage
class FileStorage implements StorageInterface (View source)
Defines the file storage.
Properties
| protected string | $collection | The storage collection. |
|
| protected string | $directory | The filesystem path for configuration objects. |
|
| protected FileCacheInterface | $fileCache | The file cache object. |
Methods
Constructs a new FileStorage.
Returns the path to the configuration file.
Returns the file extension used by the file storage for all configuration files.
Check if the directory exists and create it if not.
Returns whether a configuration object exists.
Implements Drupal\Core\Config\StorageInterface::read().
Reads configuration data from the storage.
Writes configuration data to the storage.
Deletes a configuration object from the storage.
Renames a configuration object in the storage.
Encodes configuration data into the storage-specific format.
Decodes configuration data from the storage-specific format.
Gets configuration object names starting with a given prefix.
Deletes configuration objects whose names start with a given prefix.
Creates a collection on the storage.
Gets the name of the current collection the storage is using.
Gets the existing collections.
Helper function for getAllCollectionNames().
Gets the directory for the collection.
Details
__construct(string $directory, string $collection = StorageInterface::DEFAULT_COLLECTION)
Constructs a new FileStorage.
string
getFilePath($name)
Returns the path to the configuration file.
static string
getFileExtension()
Returns the file extension used by the file storage for all configuration files.
protected
ensureStorage()
Check if the directory exists and create it if not.
bool
exists(string $name)
Returns whether a configuration object exists.
array|bool
read(string $name)
Implements Drupal\Core\Config\StorageInterface::read().
array
readMultiple(array $names)
Reads configuration data from the storage.
bool
write(string $name, array $data)
Writes configuration data to the storage.
bool
delete(string $name)
Deletes a configuration object from the storage.
bool
rename(string $name, string $new_name)
Renames a configuration object in the storage.
string
encode(array $data)
Encodes configuration data into the storage-specific format.
This is a publicly accessible static method to allow for alternative usages in data conversion scripts and also tests.
array
decode(string $raw)
Decodes configuration data from the storage-specific format.
This is a publicly accessible static method to allow for alternative usages in data conversion scripts and also tests.
array
listAll(string $prefix = '')
Gets configuration object names starting with a given prefix.
Given the following configuration objects:
- node.type.article
- node.type.page
Passing the prefix 'node.type.' will return an array containing the above names.
bool
deleteAll(string $prefix = '')
Deletes configuration objects whose names start with a given prefix.
Given the following configuration object names:
- node.type.article
- node.type.page
Passing the prefix 'node.type.' will delete the above configuration objects.
$this
createCollection(string $collection)
Creates a collection on the storage.
A configuration storage can contain multiple sets of configuration objects in partitioned collections. The collection name identifies the current collection used.
Implementations of this method must provide a new instance to avoid side effects caused by the fact that Config objects have their storage injected.
string
getCollectionName()
Gets the name of the current collection the storage is using.
array
getAllCollectionNames()
Gets the existing collections.
A configuration storage can contain multiple sets of configuration objects in partitioned collections. The collection key name identifies the current collection used.
protected array
getAllCollectionNamesHelper(string $directory)
Helper function for getAllCollectionNames().
If the file storage has the following subdirectory structure: ./another_collection/one ./another_collection/two ./collection/sub/one ./collection/sub/two this function will return:
protected string
getCollectionDirectory()
Gets the directory for the collection.