Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Core\Config;
|
Chris@0
|
4
|
Chris@0
|
5 /**
|
Chris@0
|
6 * Defines the immutable configuration object.
|
Chris@0
|
7 *
|
Chris@0
|
8 * Encapsulates all capabilities needed for runtime configuration handling
|
Chris@0
|
9 * except being able to change the configuration.
|
Chris@0
|
10 *
|
Chris@0
|
11 * If you need to be able to change configuration use
|
Chris@0
|
12 * \Drupal\Core\Form\ConfigFormBaseTrait or
|
Chris@0
|
13 * \Drupal\Core\Config\ConfigFactoryInterface::getEditable().
|
Chris@0
|
14 *
|
Chris@0
|
15 * @see \Drupal\Core\Form\ConfigFormBaseTrait
|
Chris@0
|
16 * @see \Drupal\Core\Config\ConfigFactoryInterface::getEditable()
|
Chris@0
|
17 * @see \Drupal\Core\Config\ConfigFactoryInterface::get()
|
Chris@0
|
18 *
|
Chris@0
|
19 * @ingroup config_api
|
Chris@0
|
20 */
|
Chris@0
|
21 class ImmutableConfig extends Config {
|
Chris@0
|
22
|
Chris@0
|
23 /**
|
Chris@0
|
24 * {@inheritdoc}
|
Chris@0
|
25 */
|
Chris@0
|
26 public function set($key, $value) {
|
Chris@0
|
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");
|
Chris@0
|
28 }
|
Chris@0
|
29
|
Chris@0
|
30 /**
|
Chris@0
|
31 * {@inheritdoc}
|
Chris@0
|
32 */
|
Chris@0
|
33 public function clear($key) {
|
Chris@0
|
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");
|
Chris@0
|
35 }
|
Chris@0
|
36
|
Chris@0
|
37 /**
|
Chris@0
|
38 * {@inheritdoc}
|
Chris@0
|
39 */
|
Chris@0
|
40 public function save($has_trusted_data = FALSE) {
|
Chris@0
|
41 throw new ImmutableConfigException("Can not save immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
|
Chris@0
|
42 }
|
Chris@0
|
43
|
Chris@0
|
44 /**
|
Chris@0
|
45 * Deletes the configuration object.
|
Chris@0
|
46 *
|
Chris@0
|
47 * @return \Drupal\Core\Config\Config
|
Chris@0
|
48 * The configuration object.
|
Chris@0
|
49 */
|
Chris@0
|
50 public function delete() {
|
Chris@0
|
51 throw new ImmutableConfigException("Can not delete immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
|
Chris@0
|
52 }
|
Chris@0
|
53
|
Chris@0
|
54 }
|