class 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());
  }
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides | 
|---|---|---|---|---|---|
| CacheableDependencyTrait::$cacheContexts | protected | property | Cache contexts. | ||
| CacheableDependencyTrait::$cacheMaxAge | protected | property | Cache max-age. | ||
| CacheableDependencyTrait::$cacheTags | protected | property | Cache tags. | ||
| CacheableDependencyTrait::setCacheability | protected | function | Sets cacheability; useful for value object constructors. | ||
| ConfigBase::$data | protected | property | The data of the configuration object. | ||
| ConfigBase::$name | protected | property | The name of the configuration object. | ||
| ConfigBase::castSafeStrings | protected | function | Casts any objects that implement MarkupInterface to string. | ||
| ConfigBase::clear | public | function | Unsets a value in this configuration object. | 1 | |
| ConfigBase::get | public | function | Gets data from this configuration object. | 1 | |
| ConfigBase::getCacheContexts | public | function | The cache contexts associated with this object. | Overrides CacheableDependencyTrait::getCacheContexts | |
| ConfigBase::getCacheMaxAge | public | function | The maximum age for which this object may be cached. | Overrides CacheableDependencyTrait::getCacheMaxAge | |
| ConfigBase::getCacheTags | public | function | The cache tags associated with this object. | Overrides CacheableDependencyTrait::getCacheTags | 1 | 
| ConfigBase::getName | public | function | Returns the name of this configuration object. | ||
| ConfigBase::MAX_NAME_LENGTH | constant | The maximum length of a configuration object name. | |||
| ConfigBase::merge | public | function | Merges data into a configuration object. | ||
| ConfigBase::set | public | function | Sets a value in this configuration object. | 1 | |
| ConfigBase::setData | public | function | Replaces the data of this configuration object. | 1 | |
| ConfigBase::setName | public | function | Sets the name of this configuration object. | ||
| ConfigBase::validateKeys | protected | function | Validates all keys in a passed in config array structure. | ||
| ConfigBase::validateName | public static | function | Validates the configuration object name. | ||
| DependencySerializationTrait::$_entityStorages | protected | property | An array of entity type IDs keyed by the property name of their storages. | ||
| DependencySerializationTrait::$_serviceIds | protected | property | An array of service IDs keyed by property name used for serialization. | ||
| DependencySerializationTrait::__sleep | public | function | 2 | ||
| DependencySerializationTrait::__wakeup | public | function | #[\ReturnTypeWillChange] | 2 | |
| LanguageConfigCollectionNameTrait::createConfigCollectionName | protected | function | Creates a configuration collection name based on a language code. | ||
| LanguageConfigCollectionNameTrait::getLangcodeFromCollectionName | protected | function | Converts a configuration collection name to a language code. | ||
| LanguageConfigOverride::$eventDispatcher | protected | property | The event dispatcher. | ||
| LanguageConfigOverride::delete | public | function | Deletes the configuration object. | Overrides StorableConfigBase::delete | |
| LanguageConfigOverride::getLangcode | public | function | Returns the language code of this language override. | ||
| LanguageConfigOverride::save | public | function | Saves the configuration object. | Overrides StorableConfigBase::save | |
| LanguageConfigOverride::__construct | public | function | Constructs a language override object. | ||
| RefinableCacheableDependencyTrait::addCacheableDependency | public | function | 1 | ||
| RefinableCacheableDependencyTrait::addCacheContexts | public | function | |||
| RefinableCacheableDependencyTrait::addCacheTags | public | function | |||
| RefinableCacheableDependencyTrait::mergeCacheMaxAge | public | function | |||
| StorableConfigBase::$isNew | protected | property | Whether the configuration object is new or has been saved to the storage. | ||
| StorableConfigBase::$originalData | protected | property | The data of the configuration object. | ||
| StorableConfigBase::$schemaWrapper | protected | property | The config schema wrapper object for this configuration object. | ||
| StorableConfigBase::$storage | protected | property | The storage used to load and save this configuration object. | ||
| StorableConfigBase::$typedConfigManager | protected | property | The typed config manager. | ||
| StorableConfigBase::castValue | protected | function | Casts the value to correct data type using the configuration schema. | ||
| StorableConfigBase::getSchemaWrapper | protected | function | Gets the schema wrapper for the whole configuration object. | ||
| StorableConfigBase::getStorage | public | function | Retrieves the storage used to load and save this configuration object. | ||
| StorableConfigBase::initWithData | public | function | Initializes a configuration object with pre-loaded data. | 1 | |
| StorableConfigBase::isNew | public | function | Returns whether this configuration object is new. | ||
| StorableConfigBase::validateValue | protected | function | Validate the values are allowed data types. | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.