Commit eaffcfc5 authored by alexpott's avatar alexpott

Issue #2451885 by Gábor Hojtsy: Config entities need to ship with language or are assumed undefined

parent 5f80c8ec
......@@ -83,9 +83,18 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
/**
* The language code of the entity's default language.
*
* Assumed to be English by default. ConfigEntityStorage will set an
* appropriate language when creating new entities. This default applies to
* imported default configuration where the language code is missing. Those
* should be assumed to be English. All configuration entities support third
* party settings, so even configuration entities that do not directly
* store settings involving text in a human language may have such third
* party settings attached. This means configuration entities should be in one
* of the configured languages or the built-in English.
*
* @var string
*/
protected $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
protected $langcode = 'en';
/**
* Third party entity settings.
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_view_block
......
......@@ -32,7 +32,7 @@ class ConfigImporterTest extends KernelTestBase {
*
* @var array
*/
public static $modules = array('config_test', 'system', 'config_import_test');
public static $modules = array('config_test', 'system', 'config_import_test', 'config_test_language');
protected function setUp() {
parent::setUp();
......@@ -539,4 +539,24 @@ function testIsInstallable() {
$this->assertTrue($this->container->get('config.storage')->exists($config_name));
}
/**
* Tests imported configuration entities with and without language information.
*/
function testLanguage() {
// Test imported configuration with implicit language code.
$data = $this->container->get('config.storage.installer')->read('config_test.dynamic.dotted.english');
$this->assertTrue(!isset($data['langcode']));
$this->assertEqual(
$this->config('config_test.dynamic.dotted.english')->get('langcode'),
'en'
);
// Test imported configuration with explicit language code.
$data = $this->container->get('config.storage.installer')->read('config_test.dynamic.dotted.french');
$this->assertEqual($data['langcode'], 'fr');
$this->assertEqual(
$this->config('config_test.dynamic.dotted.french')->get('langcode'),
'fr'
);
}
}
id: dotted.english
label: Default
weight: 0
protected_property: Default
# Used for testing default language code on imported config entities.
# langcode: en
id: dotted.french
label: Default
weight: 0
protected_property: Default
langcode: fr
name: 'Configuration test languages'
type: module
package: Testing
version: VERSION
core: 8.x
id: entity_test.entity_test.field_test_import
langcode: und
langcode: en
field_name: field_test_import
entity_type: entity_test
bundle: entity_test
......
id: entity_test.entity_test.field_test_import_2
langcode: und
langcode: en
field_name: field_test_import_2
entity_type: entity_test
bundle: entity_test
......
id: entity_test.test_bundle.field_test_import_2
langcode: und
langcode: en
field_name: field_test_import_2
entity_type: entity_test
bundle: test_bundle
......
id: entity_test.field_test_import
langcode: und
langcode: en
field_name: field_test_import
entity_type: entity_test
type: text
......
id: entity_test.field_test_import_2
langcode: und
langcode: en
field_name: field_test_import_2
entity_type: entity_test
type: text
......
id: entity_test.entity_test.field_test_import_staging
uuid: ea711065-6940-47cd-813d-618f64095481
langcode: und
langcode: en
field_name: field_test_import_staging
entity_type: entity_test
bundle: entity_test
......
id: entity_test.test_bundle.field_test_import_staging_2
uuid: f07794a2-d7cc-45b6-b40d-13cf021b5552
langcode: und
langcode: en
field_name: field_test_import_staging_2
entity_type: entity_test
bundle: test_bundle
......
id: entity_test.test_bundle_2.field_test_import_staging_2
uuid: 49d6dd19-5097-443d-8f00-fc79525bebce
langcode: und
langcode: en
field_name: field_test_import_staging_2
entity_type: entity_test
bundle: test_bundle_2
......
id: entity_test.field_test_import_staging
uuid: 0bf654cc-f14a-4881-b94c-76959e47466b
langcode: und
langcode: en
field_name: field_test_import_staging
entity_type: entity_test
type: text
......
id: entity_test.field_test_import_staging_2
uuid: 2165d9aa-9a0c-41a1-be02-2a49f3405c00
langcode: und
langcode: en
field_name: field_test_import_staging_2
entity_type: entity_test
type: text
......
......@@ -243,7 +243,7 @@ public function testToArray() {
'id' => 'test_entity_type.test_bundle.field_test',
'uuid' => NULL,
'status' => TRUE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'langcode' => 'en',
'field_name' => 'field_test',
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle',
......
langcode: und
langcode: en
status: true
dependencies: { }
id: file_extension_view
......
......@@ -6,7 +6,7 @@ source:
plugin: d6_field
constants:
entity_type: node
langcode: und
langcode: en
process:
entity_type: 'constants/entity_type'
status: active
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_view_argument_validate_user
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_view_argument_validate_username
......
langcode: und
langcode: en
status: true
dependencies: { }
id: entity_test_fields
......
langcode: und
langcode: en
status: true
dependencies: { }
id: entity_test_row
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_access_none
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_aggregate_count
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_ajax_view
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_area_title
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_area_view
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_argument_date
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_cache
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_click_sort
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_display_attachment
......
langcode: und
langcode: en
status: true
dependencies: { }
id: test_display_more
......