class NullStorage
Same name in other branches
- 9 core/lib/Drupal/Core/Config/NullStorage.php \Drupal\Core\Config\NullStorage
- 8.9.x core/lib/Drupal/Core/Config/NullStorage.php \Drupal\Core\Config\NullStorage
- 11.x core/lib/Drupal/Core/Config/NullStorage.php \Drupal\Core\Config\NullStorage
Defines a stub storage.
This storage is always empty; the controller reads and writes nothing.
The stub implementation is needed for synchronizing configuration during installation of a module, in which case all configuration being shipped with the module is known to be new. Therefore, the module installation process is able to short-circuit the full diff against the active configuration; the diff would yield all currently available configuration as items to remove, since they do not exist in the module's default configuration directory.
This also can be used for testing purposes.
Hierarchy
- class \Drupal\Core\Config\NullStorage implements \Drupal\Core\Config\StorageInterface
Expanded class hierarchy of NullStorage
5 files declare their use of NullStorage
- DrupalKernel.php in core/
lib/ Drupal/ Core/ DrupalKernel.php - LocaleDefaultConfigStorageTest.php in core/
modules/ locale/ tests/ src/ Kernel/ LocaleDefaultConfigStorageTest.php - NullStorageTest.php in core/
tests/ Drupal/ Tests/ Core/ Config/ NullStorageTest.php - RecipeConfigStorageWrapper.php in core/
lib/ Drupal/ Core/ Recipe/ RecipeConfigStorageWrapper.php - RecipeConfigStorageWrapperTest.php in core/
tests/ Drupal/ Tests/ Core/ Recipe/ RecipeConfigStorageWrapperTest.php
File
-
core/
lib/ Drupal/ Core/ Config/ NullStorage.php, line 19
Namespace
Drupal\Core\ConfigView source
class NullStorage implements StorageInterface {
/**
* The storage collection.
*
* @var string
*/
protected $collection;
/**
* Constructs a new NullStorage.
*
* @param string $collection
* (optional) The collection to store configuration in. Defaults to the
* default collection.
*/
public function __construct($collection = StorageInterface::DEFAULT_COLLECTION) {
$this->collection = $collection;
}
/**
* {@inheritdoc}
*/
public function exists($name) {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function read($name) {
return [];
}
/**
* {@inheritdoc}
*/
public function readMultiple(array $names) {
return [];
}
/**
* {@inheritdoc}
*/
public function write($name, array $data) {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function delete($name) {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function rename($name, $new_name) {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function encode($data) {
return $data;
}
/**
* {@inheritdoc}
*/
public function decode($raw) {
return $raw;
}
/**
* {@inheritdoc}
*/
public function listAll($prefix = '') {
return [];
}
/**
* {@inheritdoc}
*/
public function deleteAll($prefix = '') {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function createCollection($collection) {
return new static($collection);
}
/**
* {@inheritdoc}
*/
public function getAllCollectionNames() {
// Returns only non empty collections.
return [];
}
/**
* {@inheritdoc}
*/
public function getCollectionName() {
return $this->collection;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
NullStorage::$collection | protected | property | The storage collection. | |
NullStorage::createCollection | public | function | Creates a collection on the storage. | Overrides StorageInterface::createCollection |
NullStorage::decode | public | function | Decodes configuration data from the storage-specific format. | Overrides StorageInterface::decode |
NullStorage::delete | public | function | Deletes a configuration object from the storage. | Overrides StorageInterface::delete |
NullStorage::deleteAll | public | function | Deletes configuration objects whose names start with a given prefix. | Overrides StorageInterface::deleteAll |
NullStorage::encode | public | function | Encodes configuration data into the storage-specific format. | Overrides StorageInterface::encode |
NullStorage::exists | public | function | Returns whether a configuration object exists. | Overrides StorageInterface::exists |
NullStorage::getAllCollectionNames | public | function | Gets the existing collections. | Overrides StorageInterface::getAllCollectionNames |
NullStorage::getCollectionName | public | function | Gets the name of the current collection the storage is using. | Overrides StorageInterface::getCollectionName |
NullStorage::listAll | public | function | Gets configuration object names starting with a given prefix. | Overrides StorageInterface::listAll |
NullStorage::read | public | function | Reads configuration data from the storage. | Overrides StorageInterface::read |
NullStorage::readMultiple | public | function | Reads configuration data from the storage. | Overrides StorageInterface::readMultiple |
NullStorage::rename | public | function | Renames a configuration object in the storage. | Overrides StorageInterface::rename |
NullStorage::write | public | function | Writes configuration data to the storage. | Overrides StorageInterface::write |
NullStorage::__construct | public | function | Constructs a new NullStorage. | |
StorageInterface::DEFAULT_COLLECTION | constant | The default collection name. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.