class RecipeExtensionConfigStorage
Same name in other branches
- 11.x core/lib/Drupal/Core/Recipe/RecipeExtensionConfigStorage.php \Drupal\Core\Recipe\RecipeExtensionConfigStorage
Allows the recipe to select configuration from the module.
@internal This API is experimental.
Hierarchy
- class \Drupal\Core\Recipe\RecipeExtensionConfigStorage implements \Drupal\Core\Config\StorageInterface
Expanded class hierarchy of RecipeExtensionConfigStorage
File
-
core/
lib/ Drupal/ Core/ Recipe/ RecipeExtensionConfigStorage.php, line 16
Namespace
Drupal\Core\RecipeView source
final class RecipeExtensionConfigStorage implements StorageInterface {
protected readonly StorageInterface $storage;
/**
* @param string $extensionPath
* The path extension to read configuration from
* @param array $configNames
* The list of config to read from the extension. An empty array means all
* configuration.
* @param string $collection
* (optional) The collection to store configuration in. Defaults to the
* default collection.
*/
public function __construct(string $extensionPath, array $configNames, string $collection = StorageInterface::DEFAULT_COLLECTION) {
$this->storage = new RecipeConfigStorageWrapper(new FileStorage($this->extensionPath . '/config/install', $this->collection), new FileStorage($this->extensionPath . '/config/optional', $this->collection), $collection);
}
/**
* {@inheritdoc}
*/
public function exists($name) : bool {
if (!empty($this->configNames) && !in_array($name, $this->configNames, TRUE)) {
return FALSE;
}
return $this->storage
->exists($name);
}
/**
* {@inheritdoc}
*/
public function read($name) : array|bool {
if (!empty($this->configNames) && !in_array($name, $this->configNames, TRUE)) {
return FALSE;
}
return $this->storage
->read($name);
}
/**
* {@inheritdoc}
*/
public function readMultiple(array $names) : array {
if (!empty($this->configNames)) {
$names = array_intersect($this->configNames, $names);
}
return $this->storage
->readMultiple($names);
}
/**
* {@inheritdoc}
*/
public function write($name, array $data) : bool {
throw new \BadMethodCallException();
}
/**
* {@inheritdoc}
*/
public function delete($name) : bool {
throw new \BadMethodCallException();
}
/**
* {@inheritdoc}
*/
public function rename($name, $new_name) : bool {
throw new \BadMethodCallException();
}
/**
* {@inheritdoc}
*/
public function encode($data) : string {
throw new \BadMethodCallException();
}
/**
* {@inheritdoc}
*/
public function decode($raw) : array {
throw new \BadMethodCallException();
}
/**
* {@inheritdoc}
*/
public function listAll($prefix = '') : array {
$names = $this->storage
->listAll($prefix);
if (!empty($this->configNames)) {
$names = array_intersect($this->configNames, $names);
}
return $names;
}
/**
* {@inheritdoc}
*/
public function deleteAll($prefix = '') : bool {
throw new \BadMethodCallException();
}
/**
* {@inheritdoc}
*/
public function createCollection($collection) : static {
return new static($this->extensionPath, $this->configNames, $collection);
}
/**
* {@inheritdoc}
*/
public function getAllCollectionNames() : array {
return $this->storage
->getAllCollectionNames();
}
/**
* {@inheritdoc}
*/
public function getCollectionName() : string {
return $this->collection;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
RecipeExtensionConfigStorage::$storage | protected | property | ||
RecipeExtensionConfigStorage::createCollection | public | function | Creates a collection on the storage. | Overrides StorageInterface::createCollection |
RecipeExtensionConfigStorage::decode | public | function | Decodes configuration data from the storage-specific format. | Overrides StorageInterface::decode |
RecipeExtensionConfigStorage::delete | public | function | Deletes a configuration object from the storage. | Overrides StorageInterface::delete |
RecipeExtensionConfigStorage::deleteAll | public | function | Deletes configuration objects whose names start with a given prefix. | Overrides StorageInterface::deleteAll |
RecipeExtensionConfigStorage::encode | public | function | Encodes configuration data into the storage-specific format. | Overrides StorageInterface::encode |
RecipeExtensionConfigStorage::exists | public | function | Returns whether a configuration object exists. | Overrides StorageInterface::exists |
RecipeExtensionConfigStorage::getAllCollectionNames | public | function | Gets the existing collections. | Overrides StorageInterface::getAllCollectionNames |
RecipeExtensionConfigStorage::getCollectionName | public | function | Gets the name of the current collection the storage is using. | Overrides StorageInterface::getCollectionName |
RecipeExtensionConfigStorage::listAll | public | function | Gets configuration object names starting with a given prefix. | Overrides StorageInterface::listAll |
RecipeExtensionConfigStorage::read | public | function | Reads configuration data from the storage. | Overrides StorageInterface::read |
RecipeExtensionConfigStorage::readMultiple | public | function | Reads configuration data from the storage. | Overrides StorageInterface::readMultiple |
RecipeExtensionConfigStorage::rename | public | function | Renames a configuration object in the storage. | Overrides StorageInterface::rename |
RecipeExtensionConfigStorage::write | public | function | Writes configuration data to the storage. | Overrides StorageInterface::write |
RecipeExtensionConfigStorage::__construct | public | function | ||
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.