Issue #2245721 by vijaycs85, YesCT: Add missing configuration schema in language component.
parent
f710a6c92e
commit
26eb01c06d
|
|
@ -106,3 +106,32 @@ language.entity.*:
|
||||||
langcode:
|
langcode:
|
||||||
type: string
|
type: string
|
||||||
label: 'Default language'
|
label: 'Default language'
|
||||||
|
|
||||||
|
language.settings:
|
||||||
|
type: mapping
|
||||||
|
label: 'Language settings'
|
||||||
|
mapping:
|
||||||
|
entities:
|
||||||
|
type: sequence
|
||||||
|
label: 'Entity type'
|
||||||
|
sequence:
|
||||||
|
- type: sequence
|
||||||
|
label: 'Bundle'
|
||||||
|
sequence:
|
||||||
|
- type: mapping
|
||||||
|
label: 'Custom language settings'
|
||||||
|
mapping:
|
||||||
|
language:
|
||||||
|
type: mapping
|
||||||
|
label: 'Custom language settings'
|
||||||
|
mapping:
|
||||||
|
default_configuration:
|
||||||
|
type: mapping
|
||||||
|
label: 'Default language'
|
||||||
|
mapping:
|
||||||
|
langcode:
|
||||||
|
type: string
|
||||||
|
label: 'Default language'
|
||||||
|
language_show:
|
||||||
|
type: boolean
|
||||||
|
label: 'Show language selector on create and edit pages'
|
||||||
|
|
|
||||||
|
|
@ -348,7 +348,7 @@ function language_get_default_configuration_settings_key($entity_type, $bundle)
|
||||||
// Replace all the characters that are not letters, numbers or "_" with "_".
|
// Replace all the characters that are not letters, numbers or "_" with "_".
|
||||||
$entity_type = preg_replace('/[^0-9a-zA-Z_]/', "_", $entity_type);
|
$entity_type = preg_replace('/[^0-9a-zA-Z_]/', "_", $entity_type);
|
||||||
$bundle = preg_replace('/[^0-9a-zA-Z_]/', "_", $bundle);
|
$bundle = preg_replace('/[^0-9a-zA-Z_]/', "_", $bundle);
|
||||||
return $entity_type . '.' . $bundle . '.language.default_configuration';
|
return 'entities.' . $entity_type . '.' . $bundle . '.language.default_configuration';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains \Drupal\language\Tests\LanguageConfigSchemaTest.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Drupal\language\Tests;
|
||||||
|
|
||||||
|
use Drupal\config\Tests\ConfigSchemaTestBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the language config schema.
|
||||||
|
*/
|
||||||
|
class LanguageConfigSchemaTest extends ConfigSchemaTestBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modules to enable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $modules = array('language');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A user with administrative permissions.
|
||||||
|
*
|
||||||
|
* @var \Drupal\user\UserInterface
|
||||||
|
*/
|
||||||
|
protected $adminUser;
|
||||||
|
|
||||||
|
public static function getInfo() {
|
||||||
|
return array(
|
||||||
|
'name' => 'Language config schema',
|
||||||
|
'description' => 'Ensures the language config schema is correct.',
|
||||||
|
'group' => 'Language',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
// Create user.
|
||||||
|
$this->adminUser = $this->drupalCreateUser(array('administer languages'));
|
||||||
|
$this->drupalLogin($this->adminUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether the language config schema is valid.
|
||||||
|
*/
|
||||||
|
function testValidLanguageConfigSchema() {
|
||||||
|
// Make sure no language configuration available by default.
|
||||||
|
$config_data = \Drupal::config('language.settings')->get();
|
||||||
|
$this->assertTrue(empty($config_data));
|
||||||
|
|
||||||
|
$settings_path = 'admin/config/regional/content-language';
|
||||||
|
|
||||||
|
// Enable translation for menu link.
|
||||||
|
$edit['entity_types[menu_link]'] = TRUE;
|
||||||
|
$edit['settings[menu_link][menu_link][settings][language][language_show]'] = TRUE;
|
||||||
|
|
||||||
|
// Enable translation for user.
|
||||||
|
$edit['entity_types[user]'] = TRUE;
|
||||||
|
$edit['settings[user][user][settings][language][language_show]'] = TRUE;
|
||||||
|
$edit['settings[user][user][settings][language][langcode]'] = 'en';
|
||||||
|
|
||||||
|
$this->drupalPostForm($settings_path, $edit, t('Save'));
|
||||||
|
|
||||||
|
$config_data = \Drupal::config('language.settings')->get();
|
||||||
|
// Make sure configuration saved correctly.
|
||||||
|
$this->assertTrue($config_data['entities']['menu_link']['menu_link']['language']['default_configuration']['language_show']);
|
||||||
|
|
||||||
|
$this->assertConfigSchema(\Drupal::service('config.typed'), 'language.settings', $config_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -460,7 +460,8 @@ function node_uninstall() {
|
||||||
foreach ($types as $config_name) {
|
foreach ($types as $config_name) {
|
||||||
$type = \Drupal::config($config_name)->get('type');
|
$type = \Drupal::config($config_name)->get('type');
|
||||||
if (\Drupal::moduleHandler()->moduleExists('language')) {
|
if (\Drupal::moduleHandler()->moduleExists('language')) {
|
||||||
\Drupal::config('language.settings')->clear('node. ' . $type . '.language.default_configuration')->save();
|
$key = language_get_default_configuration_settings_key('node', $type);
|
||||||
|
\Drupal::config('language.settings')->clear($key)->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue