getDefaultConfigLangcode example

/** * Whether the given configuration is supported for interface translation. * * @param string $name * The configuration name. * * @return bool * TRUE if interface translation is supported. */
  public function isSupported($name) {
    return $this->getDefaultConfigLangcode($name) == 'en' && $this->configStorage->read($name);
  }

  /** * Indicates whether configuration translations are being updated from locale. * * @return bool * Whether or not configuration translations are currently being updated. * If TRUE, LocaleConfigManager is in control of the process and the * reference data is locale's storage. Changes made to active configuration * and overrides in this case should not feed back to locale storage. * On the other hand, when not updating from locale and configuration * translations change, we need to feed back to the locale storage. */
$this->assertFalse($translation_after->isNew());
    $translation_after->setString('updated_translation')->save();
  }

  /** * Tests getDefaultConfigLangcode(). */
  public function testGetDefaultConfigLangcode() {
    // Install the Language module's configuration so we can use the     // module_installer service.     $this->installConfig(['language']);
    $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode('locale_test_translate.settings'), 'Before installing a module the locale config manager can not access the shipped configuration.');
    \Drupal::service('module_installer')->install(['locale_test_translate']);
    $this->assertEquals('en', \Drupal::service('locale.config_manager')->getDefaultConfigLangcode('locale_test_translate.settings'), 'After installing a module the locale config manager can get the shipped configuration langcode.');

    $simple_config = \Drupal::configFactory()->getEditable('locale_test_translate.simple_config_extra');
    $simple_config->set('foo', 'bar')->save();
    $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode($simple_config->getName()), 'Simple config created through the API is not treated as shipped configuration.');

    $block = Block::create([
      'id' => 'test_default_config',
      'theme' => 'stark',
      'status' => TRUE,
      
Home | Imprint | This part of the site doesn't use cookies.