class ThemeSettings extends ConfigBase (View source)

Provides a configuration API wrapper for runtime merged theme settings.

Theme settings use configuration for base values but the runtime theme settings are calculated based on various site settings and are therefore not persisted.

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 string $theme

The theme of the theme settings object.

Methods

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

$this
setCacheability(CacheableDependencyInterface $cacheability)

Sets cacheability; useful for value object constructors.

string[]
getCacheTags()

The cache tags associated with this object.

addCacheableDependency($other_object)

{@inheritdoc}

addCacheContexts(array $cache_contexts)

{@inheritdoc}

addCacheTags(array $cache_tags)

{@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.

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.

mixed
castSafeStrings(mixed $data)

Casts any objects that implement MarkupInterface to string.

__construct(string $theme)

Constructs a theme settings object.

string
getTheme()

Returns the theme of this theme settings object.

Details

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

protected $this setCacheability(CacheableDependencyInterface $cacheability)

Sets cacheability; useful for value object constructors.

Parameters

CacheableDependencyInterface $cacheability

The cacheability to set.

Return Value

$this

string[] getCacheTags()

The cache tags associated with this object.

When this object is modified, these cache tags will be invalidated.

Return Value

string[]

A set of cache tags.

getCacheContexts()

{@inheritdoc}

getCacheMaxAge()

{@inheritdoc}

addCacheableDependency($other_object)

{@inheritdoc}

Parameters

$other_object

addCacheContexts(array $cache_contexts)

{@inheritdoc}

Parameters

array $cache_contexts

addCacheTags(array $cache_tags)

{@inheritdoc}

Parameters

array $cache_tags

mergeCacheMaxAge($max_age)

{@inheritdoc}

Parameters

$max_age

string getName()

Returns the name of this configuration object.

Return Value

string

The name of the configuration object.

$this setName(string $name)

Sets the name of this configuration object.

Parameters

string $name

The name of the configuration object.

Return Value

$this

The configuration object.

static validateName(string $name)

Validates the configuration object name.

Parameters

string $name

The name of the configuration object.

Exceptions

ConfigNameException

See also

Config::MAX_NAME_LENGTH

mixed get(string $key = '')

Gets data from this configuration object.

Parameters

string $key

A string that maps to a key within the configuration data. For instance in the following configuration array: @code array( 'foo' => array( 'bar' => 'baz', ), ); @endcode A key of 'foo.bar' would return the string 'baz'. However, a key of 'foo' would return array('bar' => 'baz'). If no key is specified, then the entire data array is returned.

Return Value

mixed

The data that was requested.

$this setData(array $data)

Replaces the data of this configuration object.

Parameters

array $data

The new configuration data.

Return Value

$this

The configuration object.

Exceptions

ConfigValueException

$this set(string $key, mixed $value)

Sets a value in this configuration object.

Parameters

string $key

Identifier to store value in configuration.

mixed $value

Value to associate with identifier.

Return Value

$this

The configuration object.

Exceptions

ConfigValueException

protected null validateKeys(array $data)

Validates all keys in a passed in config array structure.

Parameters

array $data

Configuration array structure.

Return Value

null

Exceptions

ConfigValueException

$this clear(string $key)

Unsets a value in this configuration object.

Parameters

string $key

Name of the key whose value should be unset.

Return Value

$this

The configuration object.

$this merge(array $data_to_merge)

Merges data into a configuration object.

Parameters

array $data_to_merge

An array containing data to merge.

Return Value

$this

The configuration object.

protected mixed castSafeStrings(mixed $data)

Casts any objects that implement MarkupInterface to string.

Parameters

mixed $data

The configuration data.

Return Value

mixed

The data with any safe strings cast to string.

__construct(string $theme)

Constructs a theme settings object.

Parameters

string $theme

The name of the theme settings object being constructed.

string getTheme()

Returns the theme of this theme settings object.

Return Value

string

The theme of this theme settings object.