class NormalizedReadOnlyStorage in Configuration Normalizer 2.0.x
Same name and namespace in other branches
- 8 src/Config/NormalizedReadOnlyStorage.php \Drupal\config_normalizer\Config\NormalizedReadOnlyStorage
Defines the normalized read only storage.
Hierarchy
- class \Drupal\Core\Config\ReadOnlyStorage implements StorageInterface
- class \Drupal\config_normalizer\Config\NormalizedReadOnlyStorage implements NormalizedReadOnlyStorageInterface
Expanded class hierarchy of NormalizedReadOnlyStorage
File
- src/
Config/ NormalizedReadOnlyStorage.php, line 12
Namespace
Drupal\config_normalizer\ConfigView source
class NormalizedReadOnlyStorage extends ReadOnlyStorage implements NormalizedReadOnlyStorageInterface {
/**
* The config item normalizer.
*
* @var \Drupal\config_normalizer\ConfigNormalizerInterface
*/
protected $normalizer;
/**
* Create a NormalizedReadOnlyStorage decorating another storage.
*
* @param \Drupal\Core\Config\StorageInterface $storage
* The decorated storage.
* @param \Drupal\config_normalizer\ConfigNormalizerInterface|mixed $normalizer
* The normalization manager. In 2.0.0 we will add a typehint.
* @param array $context
* (optional, deprecated) This parameter will be removed in 2.0.0.
*/
public function __construct(StorageInterface $storage, $normalizer, array $context = []) {
parent::__construct($storage);
if (!$normalizer instanceof ConfigNormalizerInterface) {
$normalizer = \Drupal::service('config_normalizer.normalizer');
}
$this->normalizer = $normalizer;
}
/**
* {@inheritdoc}
*/
public function getContext() {
return [];
}
/**
* {@inheritdoc}
*/
public function setContext(array $context = []) {
}
/**
* {@inheritdoc}
*/
public function read($name) {
$data = parent::read($name);
$data = $this
->normalize($name, $data);
return $data;
}
/**
* {@inheritdoc}
*/
public function readMultiple(array $names) {
$list = parent::readMultiple($names);
foreach ($list as $name => &$data) {
$data = $this
->normalize($name, $data);
}
return $list;
}
/**
* {@inheritdoc}
*/
public function createCollection($collection) {
return new static($this->storage
->createCollection($collection), $this->normalizer);
}
/**
* Normalizes configuration data.
*
* @param string $name
* The name of a configuration object to load.
* @param array|bool $data
* The configuration data to normalize.
*
* @return array|bool
* The configuration data stored for the configuration object name. If no
* configuration data exists for the given name, FALSE is returned.
*/
protected function normalize($name, $data) {
if (!is_bool($data)) {
$data = $this->normalizer
->normalize($name, $data);
}
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NormalizedReadOnlyStorage:: |
protected | property | The config item normalizer. | |
NormalizedReadOnlyStorage:: |
public | function |
Creates a collection on the storage. Overrides ReadOnlyStorage:: |
|
NormalizedReadOnlyStorage:: |
public | function |
Gets the context to be used for normalization. Overrides NormalizedReadOnlyStorageInterface:: |
|
NormalizedReadOnlyStorage:: |
protected | function | Normalizes configuration data. | |
NormalizedReadOnlyStorage:: |
public | function |
Reads configuration data from the storage. Overrides ReadOnlyStorage:: |
|
NormalizedReadOnlyStorage:: |
public | function |
Reads configuration data from the storage. Overrides ReadOnlyStorage:: |
|
NormalizedReadOnlyStorage:: |
public | function |
Sets the context to be used for normalization. Overrides NormalizedReadOnlyStorageInterface:: |
|
NormalizedReadOnlyStorage:: |
public | function |
Create a NormalizedReadOnlyStorage decorating another storage. Overrides ReadOnlyStorage:: |
|
NormalizedReadOnlyStorageInterface:: |
constant | The default context for normalization. | ||
NormalizedReadOnlyStorageInterface:: |
constant | The default normalization mode. | ||
NormalizedReadOnlyStorageInterface:: |
constant | Mode in which the storage is being prepared for comparison. | ||
NormalizedReadOnlyStorageInterface:: |
constant | Mode in which the storage is being prepared for providing configuration. | ||
ReadOnlyStorage:: |
protected | property | The config storage that we are decorating. | |
ReadOnlyStorage:: |
public | function |
Decodes configuration data from the storage-specific format. Overrides StorageInterface:: |
|
ReadOnlyStorage:: |
public | function |
Deletes a configuration object from the storage. Overrides StorageInterface:: |
|
ReadOnlyStorage:: |
public | function |
Deletes configuration objects whose names start with a given prefix. Overrides StorageInterface:: |
|
ReadOnlyStorage:: |
public | function |
Encodes configuration data into the storage-specific format. Overrides StorageInterface:: |
|
ReadOnlyStorage:: |
public | function |
Returns whether a configuration object exists. Overrides StorageInterface:: |
|
ReadOnlyStorage:: |
public | function |
Gets the existing collections. Overrides StorageInterface:: |
|
ReadOnlyStorage:: |
public | function |
Gets the name of the current collection the storage is using. Overrides StorageInterface:: |
|
ReadOnlyStorage:: |
public | function |
Gets configuration object names starting with a given prefix. Overrides StorageInterface:: |
|
ReadOnlyStorage:: |
public | function |
Renames a configuration object in the storage. Overrides StorageInterface:: |
|
ReadOnlyStorage:: |
public | function |
Writes configuration data to the storage. Overrides StorageInterface:: |
|
StorageInterface:: |
constant | The default collection name. |