function LanguageTestHooks::languageTypesInfoAlter

Implements hook_language_types_info_alter().

Attributes

#[Hook('language_types_info_alter')]

File

core/modules/language/tests/language_test/src/Hook/LanguageTestHooks.php, line 58

Class

LanguageTestHooks
Hook implementations for language_test.

Namespace

Drupal\language_test\Hook

Code

public function languageTypesInfoAlter(array &$language_types) : void {
  if (\Drupal::keyValue('language_test')->get('content_language_type')) {
    $language_types[LanguageInterface::TYPE_CONTENT]['locked'] = FALSE;
    unset($language_types[LanguageInterface::TYPE_CONTENT]['fixed']);
    // By default languages are not configurable. Make
    // LanguageInterface::TYPE_CONTENT configurable.
    $config = \Drupal::configFactory()->getEditable('language.types');
    $configurable = $config->get('configurable');
    if (!in_array(LanguageInterface::TYPE_CONTENT, $configurable)) {
      $configurable[] = LanguageInterface::TYPE_CONTENT;
      $config->set('configurable', $configurable)
        ->save();
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.