class LanguageConfigOverride
Same name and namespace in other branches
- 10 core/modules/language/src/Config/LanguageConfigOverride.php \Drupal\language\Config\LanguageConfigOverride
- 11.x core/modules/language/src/Config/LanguageConfigOverride.php \Drupal\language\Config\LanguageConfigOverride
- 8.9.x core/modules/language/src/Config/LanguageConfigOverride.php \Drupal\language\Config\LanguageConfigOverride
Defines language configuration overrides.
Hierarchy
- class \Drupal\Core\Config\ConfigBase implements \Drupal\Core\Cache\RefinableCacheableDependencyInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Cache\RefinableCacheableDependencyTrait
- class \Drupal\Core\Config\StorableConfigBase extends \Drupal\Core\Config\ConfigBase
- class \Drupal\language\Config\LanguageConfigOverride uses \Drupal\language\Config\LanguageConfigCollectionNameTrait extends \Drupal\Core\Config\StorableConfigBase
- class \Drupal\Core\Config\StorableConfigBase extends \Drupal\Core\Config\ConfigBase
Expanded class hierarchy of LanguageConfigOverride
5 files declare their use of LanguageConfigOverride
- ElementInterface.php in core/
modules/ config_translation/ src/ FormElement/ ElementInterface.php - FormElementBase.php in core/
modules/ config_translation/ src/ FormElement/ FormElementBase.php - LanguageConfigOverrideTest.php in core/
modules/ language/ tests/ src/ Unit/ Config/ LanguageConfigOverrideTest.php - ListElement.php in core/
modules/ config_translation/ src/ FormElement/ ListElement.php - PluralVariants.php in core/
modules/ config_translation/ src/ FormElement/ PluralVariants.php
File
-
core/
modules/ language/ src/ Config/ LanguageConfigOverride.php, line 14
Namespace
Drupal\language\ConfigView source
class LanguageConfigOverride extends StorableConfigBase {
use LanguageConfigCollectionNameTrait;
/**
* The event dispatcher.
*
* @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface
*/
protected $eventDispatcher;
/**
* Constructs a language override object.
*
* @param string $name
* The name of the configuration object being overridden.
* @param \Drupal\Core\Config\StorageInterface $storage
* A storage controller object to use for reading and writing the
* configuration override.
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config
* The typed configuration manager service.
* @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
*/
public function __construct($name, StorageInterface $storage, TypedConfigManagerInterface $typed_config, EventDispatcherInterface $event_dispatcher) {
$this->name = $name;
$this->storage = $storage;
$this->typedConfigManager = $typed_config;
$this->eventDispatcher = $event_dispatcher;
}
/**
* {@inheritdoc}
*/
public function save($has_trusted_data = FALSE) {
if (!$has_trusted_data) {
// @todo Use configuration schema to validate.
// https://www.drupal.org/node/2270399
// Perform basic data validation.
foreach ($this->data as $key => $value) {
$this->validateValue($key, $value);
}
}
$this->storage
->write($this->name, $this->data);
// Invalidate the cache tags not only when updating, but also when creating,
// because a language config override object uses the same cache tag as the
// default configuration object. Hence creating a language override is like
// an update of configuration, but only for a specific language.
Cache::invalidateTags($this->getCacheTags());
$this->isNew = FALSE;
$this->eventDispatcher
->dispatch(new LanguageConfigOverrideCrudEvent($this), LanguageConfigOverrideEvents::SAVE_OVERRIDE);
$this->originalData = $this->data;
return $this;
}
/**
* {@inheritdoc}
*/
public function delete() {
$this->data = [];
$this->storage
->delete($this->name);
Cache::invalidateTags($this->getCacheTags());
$this->isNew = TRUE;
$this->eventDispatcher
->dispatch(new LanguageConfigOverrideCrudEvent($this), LanguageConfigOverrideEvents::DELETE_OVERRIDE);
$this->originalData = $this->data;
return $this;
}
/**
* Returns the language code of this language override.
*
* @return string
* The language code.
*/
public function getLangcode() {
return $this->getLangcodeFromCollectionName($this->getStorage()
->getCollectionName());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.