StorableConfigBase
abstract class StorableConfigBase extends ConfigBase (View source)
Provides a base class for configuration objects with storage support.
Encapsulates all capabilities needed for configuration handling for a specific configuration object, including storage and data type casting.
The default implementation in \Drupal\Core\Config\Config adds support for runtime overrides. Extend from StorableConfigBase directly to manage configuration with a storage backend that does not support overrides.
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. |
|
| protected Element | $schemaWrapper | The config schema wrapper object for this configuration object. |
|
| protected TypedConfigManagerInterface | $typedConfigManager | The typed config manager. |
|
| protected bool | $isNew | Whether the configuration object is new or has been saved to the storage. |
|
| protected array | $originalData | The data of the configuration object. |
Methods
Sets cacheability; useful for value object constructors.
Validates all keys in a passed in config array structure.
Casts any objects that implement MarkupInterface to string.
Saves the configuration object.
Deletes the configuration object.
Initializes a configuration object with pre-loaded data.
Returns whether this configuration object is new.
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.
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.
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.
abstract $this
save(bool $has_trusted_data = FALSE)
Saves the configuration object.
Must invalidate the cache tags associated with the configuration object.
abstract $this
delete()
Deletes the configuration object.
Must invalidate the cache tags associated with the configuration object.
$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.