ConfigBase
abstract class ConfigBase implements RefinableCacheableDependencyInterface (View source)
Provides a base class for configuration objects with get/set support.
Encapsulates all capabilities needed for runtime configuration handling for a specific configuration object.
Extend directly from this class for non-storable configuration where the configuration API is desired but storage is not possible; for example, if the data is derived at runtime. For storable configuration, extend \Drupal\Core\Config\StorableConfigBase.
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. |
|
| protected array | $data | The data of the configuration object. |
Methods
Sets cacheability; useful for value object constructors.
The cache tags associated with this object.
The cache contexts associated with this object.
The maximum age for which this object may be cached.
Returns the name of this configuration object.
Sets the name of this configuration object.
Validates the configuration object name.
Gets data from this configuration object.
Replaces the data of this configuration object.
Sets a value in this configuration object.
Validates all keys in a passed in config array structure.
Unsets a value in this configuration object.
Merges data into a configuration object.
Casts any objects that implement MarkupInterface to string.
Details
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
protected $this
setCacheability(CacheableDependencyInterface $cacheability)
Sets cacheability; useful for value object constructors.
string[]
getCacheTags()
The cache tags associated with this object.
When this object is modified, these cache tags will be invalidated.
string[]
getCacheContexts()
The cache contexts associated with this object.
These identify a specific variation/representation of the object.
Cache contexts are tokens: placeholders that are converted to cache keys by the @cache_contexts_manager service. The replacement value depends on the request context (the current URL, language, and so on). They're converted before storing an object in cache.
int
getCacheMaxAge()
The maximum age for which this object may be cached.
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.
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.