class ImmutableConfig

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Config/ImmutableConfig.php \Drupal\Core\Config\ImmutableConfig
  2. 10 core/lib/Drupal/Core/Config/ImmutableConfig.php \Drupal\Core\Config\ImmutableConfig
  3. 11.x core/lib/Drupal/Core/Config/ImmutableConfig.php \Drupal\Core\Config\ImmutableConfig

Defines the immutable configuration object.

Encapsulates all capabilities needed for runtime configuration handling except being able to change the configuration.

If you need to be able to change configuration use \Drupal\Core\Form\ConfigFormBaseTrait or \Drupal\Core\Config\ConfigFactoryInterface::getEditable().

Hierarchy

Expanded class hierarchy of ImmutableConfig

See also

\Drupal\Core\Form\ConfigFormBaseTrait

\Drupal\Core\Config\ConfigFactoryInterface::getEditable()

\Drupal\Core\Config\ConfigFactoryInterface::get()

Related topics

9 files declare their use of ImmutableConfig
ConfigEntityStorageTest.php in core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php
CronTest.php in core/tests/Drupal/Tests/Core/CronTest.php
DateTimeIso8601NormalizerTest.php in core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php
DateTimeNormalizerTest.php in core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php
HttpExceptionNormalizerTest.php in core/modules/jsonapi/tests/src/Unit/Normalizer/HttpExceptionNormalizerTest.php

... See full list

File

core/lib/Drupal/Core/Config/ImmutableConfig.php, line 21

Namespace

Drupal\Core\Config
View source
class ImmutableConfig extends Config {
    
    /**
     * {@inheritdoc}
     */
    public function set($key, $value) {
        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");
    }
    
    /**
     * {@inheritdoc}
     */
    public function clear($key) {
        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");
    }
    
    /**
     * {@inheritdoc}
     */
    public function save($has_trusted_data = FALSE) {
        throw new ImmutableConfigException("Can not save immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
    }
    
    /**
     * Deletes the configuration object.
     *
     * @return \Drupal\Core\Config\Config
     *   The configuration object.
     */
    public function delete() {
        throw new ImmutableConfigException("Can not delete immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
Config::$eventDispatcher protected property An event dispatcher instance to use for configuration events.
Config::$moduleOverrides protected property The current module overrides.
Config::$overriddenData protected property The current runtime data.
Config::$settingsOverrides protected property The current settings overrides.
Config::get public function Gets data from this configuration object. Overrides ConfigBase::get
Config::getOriginal public function Gets original data from this configuration object.
Config::getRawData public function Gets the raw data without overrides.
Config::hasOverrides public function Determines if overrides are applied to a key for this configuration object.
Config::initWithData public function Initializes a configuration object with pre-loaded data. Overrides StorableConfigBase::initWithData
Config::resetOverriddenData protected function Resets the current data, so overrides are re-applied.
Config::setData public function Replaces the data of this configuration object. Overrides ConfigBase::setData
Config::setModuleOverride public function Sets module overrides for this configuration object.
Config::setOverriddenData protected function Sets the current data for this configuration object.
Config::setSettingsOverride public function Sets settings.php overrides for this configuration object.
Config::__construct public function Constructs a configuration object.
ConfigBase::$data protected property The data of the configuration object.
ConfigBase::$name protected property The name of the configuration object.
ConfigBase::castSafeStrings protected function Casts any objects that implement MarkupInterface to string.
ConfigBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
ConfigBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
ConfigBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags 1
ConfigBase::getName public function Returns the name of this configuration object.
ConfigBase::MAX_NAME_LENGTH constant The maximum length of a configuration object name.
ConfigBase::merge public function Merges data into a configuration object.
ConfigBase::setName public function Sets the name of this configuration object.
ConfigBase::validateKeys protected function Validates all keys in a passed in config array structure.
ConfigBase::validateName public static function Validates the configuration object name.
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
ImmutableConfig::clear public function Unsets a value in this configuration object. Overrides Config::clear
ImmutableConfig::delete public function Deletes the configuration object. Overrides Config::delete
ImmutableConfig::save public function Saves the configuration object. Overrides Config::save
ImmutableConfig::set public function Sets a value in this configuration object. Overrides Config::set
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
StorableConfigBase::$isNew protected property Whether the configuration object is new or has been saved to the storage.
StorableConfigBase::$originalData protected property The data of the configuration object.
StorableConfigBase::$schemaWrapper protected property The config schema wrapper object for this configuration object.
StorableConfigBase::$storage protected property The storage used to load and save this configuration object.
StorableConfigBase::$typedConfigManager protected property The typed config manager.
StorableConfigBase::castValue protected function Casts the value to correct data type using the configuration schema.
StorableConfigBase::getSchemaWrapper protected function Gets the schema wrapper for the whole configuration object.
StorableConfigBase::getStorage public function Retrieves the storage used to load and save this configuration object.
StorableConfigBase::isNew public function Returns whether this configuration object is new.
StorableConfigBase::validateValue protected function Validate the values are allowed data types.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.