ImmutableConfig
class ImmutableConfig extends Config (View source)
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().
Traits
Provides dependency injection friendly methods for serialization.
Trait for \Drupal\Core\Cache\RefinableCacheableDependencyInterface.
Trait for \Drupal\Core\Cache\CacheableDependencyInterface.
Constants
| MAX_NAME_LENGTH |
The maximum length of a configuration object name. Many filesystems (including HFS, NTFS, and ext4) have a maximum file name length of 255 characters. To ensure that no configuration objects incompatible with this limitation are created, we enforce a maximum name length of 250 characters (leaving 5 characters for the file extension). |
Properties
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected string[] | $cacheContexts | Cache contexts. |
from CacheableDependencyTrait |
| protected string[] | $cacheTags | Cache tags. |
from CacheableDependencyTrait |
| protected int | $cacheMaxAge | Cache max-age. |
from CacheableDependencyTrait |
| protected string | $name | The name of the configuration object. |
from ConfigBase |
| protected array | $data | The data of the configuration object. |
from ConfigBase |
| protected StorageInterface | $storage | The storage used to load and save this configuration object. |
from StorableConfigBase |
| protected Element | $schemaWrapper | The config schema wrapper object for this configuration object. |
from StorableConfigBase |
| protected TypedConfigManagerInterface | $typedConfigManager | The typed config manager. |
from StorableConfigBase |
| protected bool | $isNew | Whether the configuration object is new or has been saved to the storage. |
from StorableConfigBase |
| protected array | $originalData | The data of the configuration object. |
from StorableConfigBase |
| protected EventDispatcherInterface | $eventDispatcher | An event dispatcher instance to use for configuration events. |
from Config |
| protected array | $overriddenData | The current runtime data. |
from Config |
| protected array | $moduleOverrides | The current module overrides. |
from Config |
| protected array | $settingsOverrides | The current settings overrides. |
from Config |
Methods
Sets cacheability; useful for value object constructors.
Sets a value in this configuration object.
Validates all keys in a passed in config array structure.
Unsets a value in this configuration object.
Casts any objects that implement MarkupInterface to string.
Saves the configuration object.
Deletes the configuration object.
Initializes a configuration object with pre-loaded data.
Retrieves the storage used to load and save this configuration object.
Gets the schema wrapper for the whole configuration object.
Validate the values are allowed data types.
Casts the value to correct data type using the configuration schema.
Constructs a configuration object.
Sets settings.php overrides for this configuration object.
Sets module overrides for this configuration object.
Gets original data from this configuration object.
Determines if overrides are applied to a key for this configuration object.
Details
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
protected $this
setCacheability(CacheableDependencyInterface $cacheability)
Sets cacheability; useful for value object constructors.
getCacheTags()
{@inheritdoc}
getCacheContexts()
{@inheritdoc}
getCacheMaxAge()
{@inheritdoc}
addCacheableDependency($other_object)
{@inheritdoc}
addCacheContexts(array $cache_contexts)
{@inheritdoc}
addCacheTags(array $cache_tags)
{@inheritdoc}
mergeCacheMaxAge($max_age)
{@inheritdoc}
string
getName()
Returns the name of this configuration object.
$this
setName(string $name)
Sets the name of this configuration object.
static
validateName(string $name)
Validates the configuration object name.
in
Config at line 84
mixed
get(string $key = '')
Gets data from this configuration object.
$this
setData(array $data)
Replaces the data of this configuration object.
$this
set(string $key, mixed $value)
Sets a value in this configuration object.
protected null
validateKeys(array $data)
Validates all keys in a passed in config array structure.
$this
clear(string $key)
Unsets a value in this configuration object.
$this
merge(array $data_to_merge)
Merges data into a configuration object.
protected mixed
castSafeStrings(mixed $data)
Casts any objects that implement MarkupInterface to string.
$this
save(bool $has_trusted_data = FALSE)
Saves the configuration object.
Must invalidate the cache tags associated with the configuration object.
$this
delete()
Deletes the configuration object.
in
Config at line 75
$this
initWithData(array $data)
Initializes a configuration object with pre-loaded data.
bool
isNew()
Returns whether this configuration object is new.
StorageInterface
getStorage()
Retrieves the storage used to load and save this configuration object.
protected Element
getSchemaWrapper()
Gets the schema wrapper for the whole configuration object.
The schema wrapper is dependent on the configuration name and the whole data structure, so if the name or the data changes in any way, the wrapper should be reset.
protected null
validateValue(string $key, mixed $value)
Validate the values are allowed data types.
protected mixed
castValue(string|null $key, mixed $value)
Casts the value to correct data type using the configuration schema.
in
Config at line 65
__construct(string $name, StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config)
Constructs a configuration object.
$this
setSettingsOverride(array $data)
Sets settings.php overrides for this configuration object.
The overridden data only applies to this configuration object.
$this
setModuleOverride(array $data)
Sets module overrides for this configuration object.
protected $this
setOverriddenData()
Sets the current data for this configuration object.
Configuration overrides operate at two distinct layers: modules and settings.php. Overrides in settings.php take precedence over values provided by modules. Precedence or different module overrides is determined by the priority of the config.factory.override tagged services.
protected $this
resetOverriddenData()
Resets the current data, so overrides are re-applied.
This method should be called after the original data or the overridden data has been changed.
array
getRawData()
Gets the raw data without overrides.
mixed
getOriginal(string $key = '', bool $apply_overrides = TRUE)
Gets original data from this configuration object.
Original data is the data as it is immediately after loading from configuration storage before any changes. If this is a new configuration object it will be an empty array.
bool
hasOverrides(string $key = '')
Determines if overrides are applied to a key for this configuration object.