class NormalizedReadOnlyStorage in Configuration Normalizer 8
Same name and namespace in other branches
- 2.0.x src/Config/NormalizedReadOnlyStorage.php \Drupal\config_normalizer\Config\NormalizedReadOnlyStorage
Defines the normalized read only storage.
Hierarchy
- class \Drupal\config_normalizer\Config\NormalizedReadOnlyStorage extends \Drupal\config_filter\Config\ReadOnlyStorage implements NormalizedReadOnlyStorageInterface
Expanded class hierarchy of NormalizedReadOnlyStorage
File
- src/
Config/ NormalizedReadOnlyStorage.php, line 13
Namespace
Drupal\config_normalizer\ConfigView source
class NormalizedReadOnlyStorage extends ReadOnlyStorage implements NormalizedReadOnlyStorageInterface {
/**
* The config normalizer manager.
*
* @var \Drupal\config_normalizer\Plugin\ConfigNormalizerManager
*/
protected $normalizerManager;
/**
* The config item normalizer.
*
* @var \Drupal\config_normalizer\ConfigItemNormalizer
*/
protected $configItemNormalizer;
/**
* An array of key-value pairs to pass additional context when needed.
*
* @var array
*/
protected $context;
/**
* Create a NormalizedReadOnlyStorage decorating another storage.
*
* @param \Drupal\Core\Config\StorageInterface $storage
* The decorated storage.
* @param \Drupal\config_normalizer\Plugin\ConfigNormalizerManager $normalizer_manager
* The normalization manager.
* @param array $context
* (optional) An array of key-value pairs to pass additional context when
* needed.
*/
public function __construct(StorageInterface $storage, ConfigNormalizerManager $normalizer_manager, array $context = []) {
parent::__construct($storage);
$this->normalizerManager = $normalizer_manager;
$this->configItemNormalizer = new ConfigItemNormalizer($normalizer_manager, $context);
$this
->setContext($context);
}
/**
* {@inheritdoc}
*/
public function getContext() {
return $this->context;
}
/**
* {@inheritdoc}
*/
public function setContext(array $context = []) {
$context += NormalizedReadOnlyStorageInterface::DEFAULT_CONTEXT;
$this->context = $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->normalizerManager, $this->context);
}
/**
* Normalizes configuration data.
*
* @param string $name
* The name of a configuration object to load.
* @param array $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->configItemNormalizer
->normalize($name, $data, $this->context);
}
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NormalizedReadOnlyStorage:: |
protected | property | The config item normalizer. | |
NormalizedReadOnlyStorage:: |
protected | property | An array of key-value pairs to pass additional context when needed. | |
NormalizedReadOnlyStorage:: |
protected | property | The config normalizer manager. | |
NormalizedReadOnlyStorage:: |
public | function |
Creates a collection on the storage. Overrides StorageInterface:: |
|
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 StorageInterface:: |
|
NormalizedReadOnlyStorage:: |
public | function |
Reads configuration data from the storage. Overrides StorageInterface:: |
|
NormalizedReadOnlyStorage:: |
public | function |
Sets the context to be used for normalization. Overrides NormalizedReadOnlyStorageInterface:: |
|
NormalizedReadOnlyStorage:: |
public | function | Create a NormalizedReadOnlyStorage decorating another storage. | |
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. | ||
StorageInterface:: |
public | function | Decodes configuration data from the storage-specific format. | 8 |
StorageInterface:: |
constant | The default collection name. | ||
StorageInterface:: |
public | function | Deletes a configuration object from the storage. | 8 |
StorageInterface:: |
public | function | Deletes configuration objects whose names start with a given prefix. | 8 |
StorageInterface:: |
public | function | Encodes configuration data into the storage-specific format. | 8 |
StorageInterface:: |
public | function | Returns whether a configuration object exists. | 8 |
StorageInterface:: |
public | function | Gets the existing collections. | 8 |
StorageInterface:: |
public | function | Gets the name of the current collection the storage is using. | 8 |
StorageInterface:: |
public | function | Gets configuration object names starting with a given prefix. | 8 |
StorageInterface:: |
public | function | Renames a configuration object in the storage. | 8 |
StorageInterface:: |
public | function | Writes configuration data to the storage. | 8 |