class LanguageConfigFactoryOverride extends ConfigFactoryOverrideBase implements LanguageConfigFactoryOverrideInterface, EventSubscriberInterface (View source)

Provides language overrides for the configuration factory.

Traits

Provides a common trait for working with language override collection names.

Properties

protected StorageInterface $baseStorage

The configuration storage.

protected StorageInterface[] $storages

An array of configuration storages keyed by langcode.

protected TypedConfigManagerInterface $typedConfigManager

The typed config manager.

protected EventDispatcherInterface $eventDispatcher

An event dispatcher instance to use for configuration events.

protected LanguageInterface $language

The language object used to override configuration data.

Methods

addCollections(ConfigCollectionInfo $collection_info)

Reacts to the ConfigEvents::COLLECTION_INFO event.

onConfigSave(ConfigCrudEvent $event)

Actions to be performed to configuration override on configuration save.

onConfigDelete(ConfigCrudEvent $event)

Actions to be performed to configuration override on configuration delete.

onConfigRename(ConfigRenameEvent $event)

Actions to be performed to configuration override on configuration rename.

static 
getSubscribedEvents()

{@inheritdoc}

filterOverride(Config $config, StorableConfigBase $override)

Filters data in the override based on what is currently in configuration.

bool
filterNestedArray(array $original_data, array $override_data)

Filters data in nested arrays.

string
createConfigCollectionName(string $langcode)

Creates a configuration collection name based on a language code.

string
getLangcodeFromCollectionName(string $collection)

Converts a configuration collection name to a language code.

__construct(StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config, LanguageDefault $default_language)

Constructs the LanguageConfigFactoryOverride object.

array
loadOverrides(array $names)

Returns config overrides.

getOverride(string $langcode, string $name)

Get language override for given language and configuration name.

getStorage(string $langcode)

Returns the storage instance for a particular langcode.

string
getCacheSuffix()

The string to append to the configuration static cache name.

getLanguage()

Gets the language object used to override configuration data.

$this
setLanguage(LanguageInterface $language = NULL)

Sets the language to be used in configuration overrides.

$this
setLanguageFromDefault(LanguageDefault $language_default = NULL)

Sets the language to be used in configuration overrides from the default.

installLanguageOverrides(string $langcode)

Installs available language configuration overrides for a given langcode.

createConfigObject(string $name, string $collection = StorageInterface::DEFAULT_COLLECTION)

Creates a configuration object for use during install and synchronization.

getCacheableMetadata(string $name)

Gets the cacheability metadata associated with the config factory override.

Details

addCollections(ConfigCollectionInfo $collection_info)

Reacts to the ConfigEvents::COLLECTION_INFO event.

Parameters

ConfigCollectionInfo $collection_info

The configuration collection info event.

onConfigSave(ConfigCrudEvent $event)

Actions to be performed to configuration override on configuration save.

Parameters

ConfigCrudEvent $event

The config CRUD event.

onConfigDelete(ConfigCrudEvent $event)

Actions to be performed to configuration override on configuration delete.

Parameters

ConfigCrudEvent $event

The config CRUD event.

onConfigRename(ConfigRenameEvent $event)

Actions to be performed to configuration override on configuration rename.

Parameters

ConfigRenameEvent $event

The config rename event.

static getSubscribedEvents()

{@inheritdoc}

protected filterOverride(Config $config, StorableConfigBase $override)

Filters data in the override based on what is currently in configuration.

Parameters

Config $config

Current configuration object.

StorableConfigBase $override

Override object corresponding to the configuration to filter data in.

protected bool filterNestedArray(array $original_data, array $override_data)

Filters data in nested arrays.

Parameters

array $original_data

Original data array to filter against.

array $override_data

Override data to filter.

Return Value

bool

TRUE if $override_data was changed, FALSE otherwise.

protected string createConfigCollectionName(string $langcode)

Creates a configuration collection name based on a language code.

Parameters

string $langcode

The language code.

Return Value

string

The configuration collection name for a language code.

protected string getLangcodeFromCollectionName(string $collection)

Converts a configuration collection name to a language code.

Parameters

string $collection

The configuration collection name.

Return Value

string

The language code of the collection.

Exceptions

InvalidArgumentException

See also

\Drupal\language\Config\self::createConfigCollectionName()

__construct(StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config, LanguageDefault $default_language)

Constructs the LanguageConfigFactoryOverride object.

Parameters

StorageInterface $storage

The configuration storage engine.

EventDispatcherInterface $event_dispatcher

An event dispatcher instance to use for configuration events.

TypedConfigManagerInterface $typed_config

The typed configuration manager.

LanguageDefault $default_language

The default language.

array loadOverrides(array $names)

Returns config overrides.

Parameters

array $names

A list of configuration names that are being loaded.

Return Value

array

An array keyed by configuration name of override data. Override data contains a nested array structure of overrides.

Config getOverride(string $langcode, string $name)

Get language override for given language and configuration name.

Parameters

string $langcode

Language code.

string $name

Configuration name.

Return Value

Config

Configuration override object.

StorageInterface getStorage(string $langcode)

Returns the storage instance for a particular langcode.

Parameters

string $langcode

Language code.

Return Value

StorageInterface

The storage instance for a particular langcode.

string getCacheSuffix()

The string to append to the configuration static cache name.

Return Value

string

A string to append to the configuration static cache name.

LanguageInterface getLanguage()

Gets the language object used to override configuration data.

Return Value

LanguageInterface

The language object used to override configuration data.

$this setLanguage(LanguageInterface $language = NULL)

Sets the language to be used in configuration overrides.

Parameters

LanguageInterface $language

The language object used to override configuration data.

Return Value

$this

$this setLanguageFromDefault(LanguageDefault $language_default = NULL)

Sets the language to be used in configuration overrides from the default.

Parameters

LanguageDefault $language_default

The default language.

Return Value

$this

installLanguageOverrides(string $langcode)

Installs available language configuration overrides for a given langcode.

Parameters

string $langcode

Language code.

StorableConfigBase createConfigObject(string $name, string $collection = StorageInterface::DEFAULT_COLLECTION)

Creates a configuration object for use during install and synchronization.

If the overrider stores its overrides in configuration collections then it can have its own implementation of \Drupal\Core\Config\StorableConfigBase. Configuration overriders can link themselves to a configuration collection by listening to the \Drupal\Core\Config\ConfigEvents::COLLECTION_INFO event and adding the collections they are responsible for. Doing this will allow installation and synchronization to use the overrider's implementation of StorableConfigBase.

Parameters

string $name

The configuration object name.

string $collection

The configuration collection.

Return Value

StorableConfigBase

The configuration object for the provided name and collection.

CacheableMetadata getCacheableMetadata(string $name)

Gets the cacheability metadata associated with the config factory override.

Parameters

string $name

The name of the configuration override to get metadata for.

Return Value

CacheableMetadata

A cacheable metadata object.