class ConfigReadonlyStorage in Configuration Read-only mode 7
Same name and namespace in other branches
- 8 src/Config/ConfigReadonlyStorage.php \Drupal\config_readonly\Config\ConfigReadonlyStorage
Defines the ConfigReadonly storage controller which will fails on write operations.
Hierarchy
- class \Drupal\config_readonly\Config\ConfigReadonlyStorage extends \Drupal\Core\Config\CachedStorage
Expanded class hierarchy of ConfigReadonlyStorage
File
- lib/
Drupal/ config_readonly/ Config/ ConfigReadonlyStorage.php, line 10
Namespace
Drupal\config_readonly\ConfigView source
class ConfigReadonlyStorage extends CachedStorage {
/**
* {@inheritdoc}
*
* @throws Exception
*/
public function write($name, array $data) {
if ($this
->read($name) != $data) {
$this
->checkLock();
}
return parent::write($name, $data);
}
/**
* {@inheritdoc}
*
* @throws Exception
*/
public function delete($name) {
$this
->checkLock();
return parent::delete($name);
}
/**
* {@inheritdoc}
*
* @throws Exception
*/
public function rename($name, $new_name) {
$this
->checkLock();
return parent::rename($name, $new_name);
}
/**
* {@inheritdoc}
*
* @throws Exception
*/
public function deleteAll($prefix = '') {
$this
->checkLock();
return parent::deleteAll($prefix);
}
protected function checkLock() {
// If settings.php says to lock config changes and if the config importer
// isn't running (we do not want to lock config imports), then throw an
// exception.
if (settings()
->get('config_readonly') && \Drupal::lock()
->lockMayBeAvailable('config.importer')) {
throw new \Exception('Your site configuration active store is currently locked.');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigReadonlyStorage:: |
protected | function | ||
ConfigReadonlyStorage:: |
public | function | ||
ConfigReadonlyStorage:: |
public | function | ||
ConfigReadonlyStorage:: |
public | function | ||
ConfigReadonlyStorage:: |
public | function |