getLangcodeFromCollectionName example

$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());
  }

}

  public function installLanguageOverrides($langcode) {
    /** @var \Drupal\Core\Config\ConfigInstallerInterface $config_installer */
    $config_installer = \Drupal::service('config.installer');
    $config_installer->installCollectionDefaultConfig($this->createConfigCollectionName($langcode));
  }

  /** * {@inheritdoc} */
  public function createConfigObject($name$collection = StorageInterface::DEFAULT_COLLECTION) {
    $langcode = $this->getLangcodeFromCollectionName($collection);
    return $this->getOverride($langcode$name);
  }

  /** * {@inheritdoc} */
  public function addCollections(ConfigCollectionInfo $collection_info) {
    foreach (\Drupal::languageManager()->getLanguages() as $language) {
      $collection_info->addCollection($this->createConfigCollectionName($language->getId())$this);
    }
  }

  
Home | Imprint | This part of the site doesn't use cookies.