3 namespace Drupal\Core\Config;
6 * Defines the immutable configuration object.
8 * Encapsulates all capabilities needed for runtime configuration handling
9 * except being able to change the configuration.
11 * If you need to be able to change configuration use
12 * \Drupal\Core\Form\ConfigFormBaseTrait or
13 * \Drupal\Core\Config\ConfigFactoryInterface::getEditable().
15 * @see \Drupal\Core\Form\ConfigFormBaseTrait
16 * @see \Drupal\Core\Config\ConfigFactoryInterface::getEditable()
17 * @see \Drupal\Core\Config\ConfigFactoryInterface::get()
21 class ImmutableConfig extends Config {
26 public function set($key, $value) {
27 throw new ImmutableConfigException("Can not set values on immutable configuration {$this->getName()}:$key. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
33 public function clear($key) {
34 throw new ImmutableConfigException("Can not clear $key key in immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
40 public function save($has_trusted_data = FALSE) {
41 throw new ImmutableConfigException("Can not save immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
45 * Deletes the configuration object.
47 * @return \Drupal\Core\Config\Config
48 * The configuration object.
50 public function delete() {
51 throw new ImmutableConfigException("Can not delete immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");