Update to Drupal 8.0.0-rc3. For more information, see https://www.drupal.org/node/2608078
This commit is contained in:
parent
6419a031d7
commit
4afb23bbd3
762 changed files with 20080 additions and 6368 deletions
|
@ -94,7 +94,14 @@ function template_preprocess_language_negotiation_configure_form(&$variables) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for theme_language_content_settings_table().
|
||||
* Prepares variables for language content settings table templates.
|
||||
*
|
||||
* Default template: language-content-settings-table.html.twig.
|
||||
*
|
||||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - element: An associative array containing the properties of the element.
|
||||
* Properties used: #bundle_label, #title.
|
||||
*/
|
||||
function template_preprocess_language_content_settings_table(&$variables) {
|
||||
// Add a render element representing the bundle language settings table.
|
||||
|
@ -132,24 +139,10 @@ function template_preprocess_language_content_settings_table(&$variables) {
|
|||
);
|
||||
}
|
||||
|
||||
$variables['title'] = $element['#title'];
|
||||
$variables['build'] = array(
|
||||
'#title' => $element['#title'],
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
'#type' => 'table',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for an administration settings table.
|
||||
*
|
||||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - build: A render element representing a table of bundle content language
|
||||
* settings for a particular entity type.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_language_content_settings_table($variables) {
|
||||
return '<h4>' . theme_render_and_autoescape($variables['build']['#title']) . '</h4>' . theme_render_and_autoescape($variables['build']);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,6 @@ function language_theme() {
|
|||
'language_content_settings_table' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'language.admin.inc',
|
||||
'function' => 'theme_language_content_settings_table',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
19
core/modules/language/migration_templates/language.yml
Normal file
19
core/modules/language/migration_templates/language.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
id: language
|
||||
label: Languages
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: language
|
||||
process:
|
||||
id: language
|
||||
label: name
|
||||
direction:
|
||||
plugin: static_map
|
||||
source: direction
|
||||
map:
|
||||
0: ltr
|
||||
1: rtl
|
||||
weight: weight
|
||||
destination:
|
||||
plugin: entity:configurable_language
|
|
@ -136,7 +136,7 @@ class NegotiationUrlForm extends ConfigFormBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Core\Form\FormInterface::validateForm().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$languages = $this->languageManager->getLanguages();
|
||||
|
|
|
@ -144,9 +144,9 @@ class LanguageNegotiationSession extends LanguageNegotiationMethodBase implement
|
|||
foreach ($this->languageManager->getNativeLanguages() as $language) {
|
||||
$langcode = $language->getId();
|
||||
$links[$langcode] = array(
|
||||
// We need to clone the $url object to avoid using the same one for all links.
|
||||
// When the links are rendered, options are set on the $url object,
|
||||
// so if we use the same one, they would be set for all links.
|
||||
// We need to clone the $url object to avoid using the same one for all
|
||||
// links. When the links are rendered, options are set on the $url
|
||||
// object, so if we use the same one, they would be set for all links.
|
||||
'url' => clone $url,
|
||||
'title' => $language->getName(),
|
||||
'attributes' => array('class' => array('language-link')),
|
||||
|
|
|
@ -101,7 +101,7 @@ class LanguageNegotiationUrl extends LanguageNegotiationMethodBase implements In
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements Drupal\Core\PathProcessor\InboundPathProcessorInterface::processInbound().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processInbound($path, Request $request) {
|
||||
$config = $this->config->get('language.negotiation')->get('url');
|
||||
|
@ -121,7 +121,7 @@ class LanguageNegotiationUrl extends LanguageNegotiationMethodBase implements In
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements Drupal\Core\PathProcessor\InboundPathProcessorInterface::processOutbound().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
|
||||
$url_scheme = 'http';
|
||||
|
@ -200,9 +200,9 @@ class LanguageNegotiationUrl extends LanguageNegotiationMethodBase implements In
|
|||
|
||||
foreach ($this->languageManager->getNativeLanguages() as $language) {
|
||||
$links[$language->getId()] = array(
|
||||
// We need to clone the $url object to avoid using the same one for all links.
|
||||
// When the links are rendered, options are set on the $url object,
|
||||
// so if we use the same one, they would be set for all links.
|
||||
// We need to clone the $url object to avoid using the same one for all
|
||||
// links. When the links are rendered, options are set on the $url
|
||||
// object, so if we use the same one, they would be set for all links.
|
||||
'url' => clone $url,
|
||||
'title' => $language->getName(),
|
||||
'language' => $language,
|
||||
|
|
57
core/modules/language/src/Plugin/migrate/source/Language.php
Normal file
57
core/modules/language/src/Plugin/migrate/source/Language.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\language\Plugin\migrate\source\Language.
|
||||
*/
|
||||
|
||||
namespace Drupal\language\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* @MigrateSource(
|
||||
* id = "language",
|
||||
* source_provider = "locale"
|
||||
* )
|
||||
*/
|
||||
class Language extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'language' => $this->t('The language code.'),
|
||||
'name' => $this->t('The English name of the language.'),
|
||||
'native' => $this->t('The native name of the language.'),
|
||||
'direction' => $this->t('The language direction. (0 = LTR, 1 = RTL)'),
|
||||
'enabled' => $this->t('Whether the language is enabled.'),
|
||||
'plurals' => $this->t('Number of plural indexes in this language.'),
|
||||
'formula' => $this->t('PHP formula to get plural indexes.'),
|
||||
'domain' => $this->t('Domain to use for this language.'),
|
||||
'prefix' => $this->t('Path prefix used for this language.'),
|
||||
'weight' => $this->t('The language weight when listed.'),
|
||||
'javascript' => $this->t('Location of the JavaScript translation file.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array(
|
||||
'language' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('languages')->fields('languages');
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains Drupal\language\ProxyClass\LanguageConverter.
|
||||
* Contains \Drupal\language\ProxyClass\LanguageConverter.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -394,9 +394,9 @@ class LanguageSwitchingTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test language switcher links for session based negotiation.
|
||||
* Tests language switcher links for session based negotiation.
|
||||
*/
|
||||
function testLanguageSessionSwitchLinks() {
|
||||
public function testLanguageSessionSwitchLinks() {
|
||||
// Add language.
|
||||
$edit = array(
|
||||
'predefined_langcode' => 'fr',
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\language\Tests\Migrate\MigrateLanguageTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\language\Tests\Migrate;
|
||||
|
||||
use Drupal\language\ConfigurableLanguageInterface;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateLanguageTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['language'];
|
||||
|
||||
/**
|
||||
* Asserts various properties of a configurable language entity.
|
||||
*
|
||||
* @param string $id
|
||||
* The language ID.
|
||||
* @param string $label
|
||||
* The language name.
|
||||
* @param string $direction
|
||||
* (optional) The language's direction (one of the DIRECTION_* constants in
|
||||
* ConfigurableLanguageInterface). Defaults to LTR.
|
||||
* @param int $weight
|
||||
* (optional) The weight of the language. Defaults to 0.
|
||||
*/
|
||||
protected function assertLanguage($id, $label, $direction = ConfigurableLanguageInterface::DIRECTION_LTR, $weight = 0) {
|
||||
/** @var \Drupal\language\ConfigurableLanguageInterface $language */
|
||||
$language = ConfigurableLanguage::load($id);
|
||||
$this->assertTrue($language instanceof ConfigurableLanguageInterface);
|
||||
$this->assertIdentical($label, $language->label());
|
||||
$this->assertIdentical($direction, $language->getDirection());
|
||||
$this->assertIdentical(0, $language->getWeight());
|
||||
$this->assertFalse($language->isLocked());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of Drupal 6 languages to configurable language entities.
|
||||
*/
|
||||
public function testLanguageMigration() {
|
||||
$this->executeMigration('language');
|
||||
$this->assertLanguage('en', 'English');
|
||||
$this->assertLanguage('fr', 'French');
|
||||
}
|
||||
|
||||
}
|
|
@ -31,7 +31,7 @@ abstract class LanguageTestBase extends ViewKernelTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function schemaDefinition() {
|
||||
$schema = parent::schemaDefinition();
|
||||
|
@ -46,7 +46,7 @@ abstract class LanguageTestBase extends ViewKernelTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
|
@ -68,7 +68,7 @@ abstract class LanguageTestBase extends ViewKernelTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\views\Tests\ViewTestBase::dataSet().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function dataSet() {
|
||||
$data = parent::dataSet();
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to display a language content settings table.
|
||||
*
|
||||
* Available variables:
|
||||
* - title: The title of the table.
|
||||
* - build: Table of content language settings.
|
||||
*
|
||||
* @see template_preprocess_language_content_settings_table()
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
<h4>{{ title }}</h4>
|
||||
{{ build }}
|
|
@ -0,0 +1,172 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- language_test
|
||||
id: no_entity_translation_view
|
||||
label: 'No Entity Translation View'
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: no_language_entity_test
|
||||
base_field: id
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: none
|
||||
options: { }
|
||||
cache:
|
||||
type: tag
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
query_tags: { }
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Apply
|
||||
reset_button: false
|
||||
reset_button_label: Reset
|
||||
exposed_sorts_label: 'Sort by'
|
||||
expose_sort_order: true
|
||||
sort_asc_label: Asc
|
||||
sort_desc_label: Desc
|
||||
pager:
|
||||
type: full
|
||||
options:
|
||||
items_per_page: 10
|
||||
offset: 0
|
||||
id: 0
|
||||
total_pages: null
|
||||
expose:
|
||||
items_per_page: false
|
||||
items_per_page_label: 'Items per page'
|
||||
items_per_page_options: '5, 10, 25, 50'
|
||||
items_per_page_options_all: false
|
||||
items_per_page_options_all_label: '- All -'
|
||||
offset: false
|
||||
offset_label: Offset
|
||||
tags:
|
||||
previous: '‹ Previous'
|
||||
next: 'Next ›'
|
||||
first: '« First'
|
||||
last: 'Last »'
|
||||
quantity: 9
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
options:
|
||||
default_field_elements: true
|
||||
inline:
|
||||
operations: operations
|
||||
separator: ''
|
||||
hide_empty: false
|
||||
fields:
|
||||
uuid:
|
||||
id: uuid
|
||||
table: no_language_entity_test
|
||||
field: uuid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: string
|
||||
settings:
|
||||
link_to_entity: false
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
entity_type: no_language_entity_test
|
||||
entity_field: uuid
|
||||
plugin_id: field
|
||||
filters: { }
|
||||
sorts: { }
|
||||
title: 'No Entity Translation View'
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url.query_args
|
||||
tags: { }
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: no-entity-translation-view
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url.query_args
|
||||
tags: { }
|
|
@ -17,6 +17,9 @@ use Drupal\Core\Field\BaseFieldDefinition;
|
|||
* @ContentEntityType(
|
||||
* id = "no_language_entity_test",
|
||||
* label = @Translation("Test entity without language support"),
|
||||
* handlers = {
|
||||
* "views_data" = "Drupal\entity_test\EntityTestViewsData"
|
||||
* },
|
||||
* base_table = "no_language_entity_test",
|
||||
* persistent_cache = FALSE,
|
||||
* entity_keys = {
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\language\Unit\Migrate\LanguageTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\language\Unit\Migrate;
|
||||
|
||||
use Drupal\language\Plugin\migrate\source\Language;
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\language\Plugin\migrate\source\Language
|
||||
* @group language
|
||||
*/
|
||||
class LanguageTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = Language::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'language',
|
||||
),
|
||||
);
|
||||
|
||||
protected $databaseContents = array(
|
||||
'languages' => array(
|
||||
array(
|
||||
'language' => 'en',
|
||||
'name' => 'English',
|
||||
'native' => 'English',
|
||||
'direction' => '0',
|
||||
'enabled' => '1',
|
||||
'plurals' => '0',
|
||||
'formula' => '',
|
||||
'domain' => '',
|
||||
'prefix' => '',
|
||||
'weight' => '0',
|
||||
'javascript' => '',
|
||||
),
|
||||
array(
|
||||
'language' => 'fr',
|
||||
'name' => 'French',
|
||||
'native' => 'Français',
|
||||
'direction' => '0',
|
||||
'enabled' => '0',
|
||||
'plurals' => '2',
|
||||
'formula' => '($n>1)',
|
||||
'domain' => '',
|
||||
'prefix' => 'fr',
|
||||
'weight' => '0',
|
||||
'javascript' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'language' => 'en',
|
||||
'name' => 'English',
|
||||
'native' => 'English',
|
||||
'direction' => '0',
|
||||
'enabled' => '1',
|
||||
'plurals' => '0',
|
||||
'formula' => '',
|
||||
'domain' => '',
|
||||
'prefix' => '',
|
||||
'weight' => '0',
|
||||
'javascript' => '',
|
||||
),
|
||||
array(
|
||||
'language' => 'fr',
|
||||
'name' => 'French',
|
||||
'native' => 'Français',
|
||||
'direction' => '0',
|
||||
'enabled' => '0',
|
||||
'plurals' => '2',
|
||||
'formula' => '($n>1)',
|
||||
'domain' => '',
|
||||
'prefix' => 'fr',
|
||||
'weight' => '0',
|
||||
'javascript' => '',
|
||||
),
|
||||
);
|
||||
|
||||
}
|
Reference in a new issue