Chris@0: name = $name; Chris@0: $this->storage = $storage; Chris@0: $this->typedConfigManager = $typed_config; Chris@0: $this->eventDispatcher = $event_dispatcher; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function save($has_trusted_data = FALSE) { Chris@0: if (!$has_trusted_data) { Chris@0: // @todo Use configuration schema to validate. Chris@0: // https://www.drupal.org/node/2270399 Chris@0: // Perform basic data validation. Chris@0: foreach ($this->data as $key => $value) { Chris@0: $this->validateValue($key, $value); Chris@0: } Chris@0: } Chris@0: Chris@0: $this->storage->write($this->name, $this->data); Chris@0: // Invalidate the cache tags not only when updating, but also when creating, Chris@0: // because a language config override object uses the same cache tag as the Chris@0: // default configuration object. Hence creating a language override is like Chris@0: // an update of configuration, but only for a specific language. Chris@0: Cache::invalidateTags($this->getCacheTags()); Chris@0: $this->isNew = FALSE; Chris@0: $this->eventDispatcher->dispatch(LanguageConfigOverrideEvents::SAVE_OVERRIDE, new LanguageConfigOverrideCrudEvent($this)); Chris@0: $this->originalData = $this->data; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function delete() { Chris@0: $this->data = []; Chris@0: $this->storage->delete($this->name); Chris@0: Cache::invalidateTags($this->getCacheTags()); Chris@0: $this->isNew = TRUE; Chris@0: $this->eventDispatcher->dispatch(LanguageConfigOverrideEvents::DELETE_OVERRIDE, new LanguageConfigOverrideCrudEvent($this)); Chris@0: $this->originalData = $this->data; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the language code of this language override. Chris@0: * Chris@0: * @return string Chris@0: * The language code. Chris@0: */ Chris@0: public function getLangcode() { Chris@0: return $this->getLangcodeFromCollectionName($this->getStorage()->getCollectionName()); Chris@0: } Chris@0: Chris@0: }