updated core to 8.6.3

This commit is contained in:
2018-11-21 12:49:46 +01:00
parent 8ca34853a3
commit c92c348eee
521 changed files with 12199 additions and 4578 deletions
@@ -0,0 +1,28 @@
id: d7_comment_entity_translation
label: Comment entity translations
migration_tags:
- Drupal 7
- translation
- Content
class: Drupal\comment\Plugin\migrate\D7Comment
source:
plugin: d7_comment_entity_translation
process:
cid: entity_id
subject: subject
langcode: language
uid: uid
status: status
created: created
changed: changed
content_translation_source: source
content_translation_outdated: translate
destination:
plugin: entity:comment
translations: true
destination_module: content_translation
migration_dependencies:
required:
- language
- d7_entity_translation_settings
- d7_comment
@@ -0,0 +1,50 @@
id: d7_custom_block_translation
label: Custom block translations
migration_tags:
- Drupal 7
- Content
- Multilingual
source:
plugin: d7_block_custom_translation
process:
id:
plugin: migration_lookup
migration: d7_custom_block
source:
- bid
langcode: language
info:
-
plugin: callback
source:
- title_translated
- title
callable: array_filter
-
plugin: callback
callable: current
'body/value':
-
plugin: callback
source:
- body_translated
- body
callable: array_filter
-
plugin: callback
callable: current
'body/format':
plugin: migration_lookup
migration: d7_filter_format
source: format
destination:
plugin: entity:block_content
no_stub: true
translations: true
destination_module: content_translation
migration_dependencies:
required:
- d7_filter_format
- block_content_body_field
- d7_custom_block
- language
@@ -0,0 +1,36 @@
id: d7_node_entity_translation
label: Node entity translations
migration_tags:
- Drupal 7
- translation
- Content
- Multilingual
deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node_entity_translation
process:
nid: entity_id
type: type
langcode: language
title: title
uid: uid
status: status
created: created
changed: changed
promote: promote
sticky: sticky
revision_uid: revision_uid
revision_log: log
revision_timestamp: timestamp
content_translation_source: source
# Boolean indicating whether this translation needs to be updated.
content_translation_outdated: translate
destination:
plugin: entity:node
translations: true
destination_module: content_translation
migration_dependencies:
required:
- language
- d7_entity_translation_settings
- d7_node
@@ -0,0 +1,32 @@
id: d7_taxonomy_term_entity_translation
label: Taxonomy term entity translations
migration_tags:
- Drupal 7
- translation
- Content
- Multilingual
deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
source:
plugin: d7_taxonomy_term_entity_translation
process:
tid: entity_id
name: name
description/value: description
description/format: format
langcode: language
status: status
content_translation_source: source
content_translation_outdated: translate
content_translation_uid: uid
content_translation_created: created
changed: changed
forum_container: is_container
destination:
plugin: entity:taxonomy_term
translations: true
destination_module: content_translation
migration_dependencies:
required:
- language
- d7_entity_translation_settings
- d7_taxonomy_term
@@ -145,37 +145,14 @@ class ContentTranslationController extends ControllerBase {
$translations = $entity->getTranslationLanguages();
}
$add_url = new Url(
"entity.$entity_type_id.content_translation_add",
[
'source' => $original,
'target' => $language->getId(),
$entity_type_id => $entity->id(),
],
[
'language' => $language,
]
);
$edit_url = new Url(
"entity.$entity_type_id.content_translation_edit",
[
'language' => $language->getId(),
$entity_type_id => $entity->id(),
],
[
'language' => $language,
]
);
$delete_url = new Url(
"entity.$entity_type_id.content_translation_delete",
[
'language' => $language->getId(),
$entity_type_id => $entity->id(),
],
[
'language' => $language,
]
);
$options = ['language' => $language];
$add_url = $entity->toUrl('drupal:content-translation-add', $options)
->setRouteParameter('source', $original)
->setRouteParameter('target', $language->getId());
$edit_url = $entity->toUrl('drupal:content-translation-edit', $options)
->setRouteParameter('language', $language->getId());
$delete_url = $entity->toUrl('drupal:content-translation-delete', $options)
->setRouteParameter('language', $language->getId());
$operations = [
'data' => [
'#type' => 'operations',
@@ -0,0 +1,87 @@
<?php
namespace Drupal\content_translation\Plugin\migrate\source;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Row;
/**
* Gets an i18n translation from the source database.
*/
trait I18nQueryTrait {
/**
* The i18n string table name.
*
* @var string
*/
protected $i18nStringTable;
/**
* Gets the translation for the property not already in the row.
*
* For some i18n migrations there are two translation values, such as a
* translated title and a translated description, that need to be retrieved.
* Since these values are stored in separate rows of the i18nStringTable
* table we get them individually, one in the source plugin query() and the
* other in prepareRow(). The names of the properties varies, for example,
* in BoxTranslation they are 'body' and 'title' whereas in
* MenuLinkTranslation they are 'title' and 'description'. This will save both
* translations to the row.
*
* @param \Drupal\migrate\Row $row
* The current migration row which must include both a 'language' property
* and an 'objectid' property. The 'objectid' is the value for the
* 'objectid' field in the i18n_string table.
* @param string $property_not_in_row
* The name of the property to get the translation for.
* @param string $object_id_name
* The value of the objectid in the i18n table.
* @param \Drupal\migrate\Plugin\MigrateIdMapInterface $id_map
* The ID map.
*
* @return bool
* FALSE if the property has already been migrated.
*
* @throws \Drupal\migrate\MigrateException
*/
protected function getPropertyNotInRowTranslation(Row $row, $property_not_in_row, $object_id_name, MigrateIdMapInterface $id_map) {
$language = $row->getSourceProperty('language');
if (!$language) {
throw new MigrateException('No language found.');
}
$object_id = $row->getSourceProperty($object_id_name);
if (!$object_id) {
throw new MigrateException('No objectid found.');
}
// If this row has been migrated it is a duplicate so skip it.
if ($id_map->lookupDestinationIds([$object_id_name => $object_id, 'language' => $language])) {
return FALSE;
}
// Save the translation for the property already in the row.
$property_in_row = $row->getSourceProperty('property');
$row->setSourceProperty($property_in_row . '_translated', $row->getSourceProperty('translation'));
// Get the translation, if one exists, for the property not already in the
// row.
$query = $this->select($this->i18nStringTable, 'i18n')
->fields('i18n', ['lid'])
->condition('i18n.property', $property_not_in_row)
->condition('i18n.objectid', $object_id);
$query->leftJoin('locales_target', 'lt', 'i18n.lid = lt.lid');
$query->condition('lt.language', $language);
$query->addField('lt', 'translation');
$results = $query->execute()->fetchAssoc();
if (!$results) {
$row->setSourceProperty($property_not_in_row . '_translated', NULL);
}
else {
$row->setSourceProperty($property_not_in_row . '_translated', $results['translation']);
}
return TRUE;
}
}
@@ -36,18 +36,6 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
*/
protected function alterRoutes(RouteCollection $collection) {
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
// Try to get the route from the current collection.
$link_template = $entity_type->getLinkTemplate('canonical');
if (strpos($link_template, '/') !== FALSE) {
$base_path = '/' . $link_template;
}
else {
if (!$entity_route = $collection->get("entity.$entity_type_id.canonical")) {
continue;
}
$base_path = $entity_route->getPath();
}
// Inherit admin route status from edit route, if exists.
$is_admin = FALSE;
$route_name = "entity.$entity_type_id.edit_form";
@@ -55,115 +43,122 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
$is_admin = (bool) $edit_route->getOption('_admin_route');
}
$path = $base_path . '/translations';
$load_latest_revision = ContentTranslationManager::isPendingRevisionSupportEnabled($entity_type_id);
$route = new Route(
$path,
[
'_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::overview',
'entity_type_id' => $entity_type_id,
],
[
'_entity_access' => $entity_type_id . '.view',
'_access_content_translation_overview' => $entity_type_id,
],
[
'parameters' => [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
'load_latest_revision' => $load_latest_revision,
],
if ($entity_type->hasLinkTemplate('drupal:content-translation-overview')) {
$route = new Route(
$entity_type->getLinkTemplate('drupal:content-translation-overview'),
[
'_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::overview',
'entity_type_id' => $entity_type_id,
],
'_admin_route' => $is_admin,
]
);
$route_name = "entity.$entity_type_id.content_translation_overview";
$collection->add($route_name, $route);
$route = new Route(
$path . '/add/{source}/{target}',
[
'_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::add',
'source' => NULL,
'target' => NULL,
'_title' => 'Add',
'entity_type_id' => $entity_type_id,
],
[
'_entity_access' => $entity_type_id . '.view',
'_access_content_translation_manage' => 'create',
],
[
'parameters' => [
'source' => [
'type' => 'language',
],
'target' => [
'type' => 'language',
],
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
'load_latest_revision' => $load_latest_revision,
],
[
'_entity_access' => $entity_type_id . '.view',
'_access_content_translation_overview' => $entity_type_id,
],
'_admin_route' => $is_admin,
]
);
$collection->add("entity.$entity_type_id.content_translation_add", $route);
[
'parameters' => [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
'load_latest_revision' => $load_latest_revision,
],
],
'_admin_route' => $is_admin,
]
);
$route_name = "entity.$entity_type_id.content_translation_overview";
$collection->add($route_name, $route);
}
$route = new Route(
$path . '/edit/{language}',
[
'_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::edit',
'language' => NULL,
'_title' => 'Edit',
'entity_type_id' => $entity_type_id,
],
[
'_access_content_translation_manage' => 'update',
],
[
'parameters' => [
'language' => [
'type' => 'language',
],
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
'load_latest_revision' => $load_latest_revision,
],
],
'_admin_route' => $is_admin,
]
);
$collection->add("entity.$entity_type_id.content_translation_edit", $route);
if ($entity_type->hasLinkTemplate('drupal:content-translation-add')) {
$route = new Route(
$entity_type->getLinkTemplate('drupal:content-translation-add'),
[
'_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::add',
'source' => NULL,
'target' => NULL,
'_title' => 'Add',
'entity_type_id' => $entity_type_id,
$route = new Route(
$path . '/delete/{language}',
[
'_entity_form' => $entity_type_id . '.content_translation_deletion',
'language' => NULL,
'_title' => 'Delete',
'entity_type_id' => $entity_type_id,
],
[
'_access_content_translation_manage' => 'delete',
],
[
'parameters' => [
'language' => [
'type' => 'language',
],
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
'load_latest_revision' => $load_latest_revision,
],
],
'_admin_route' => $is_admin,
]
);
$collection->add("entity.$entity_type_id.content_translation_delete", $route);
[
'_entity_access' => $entity_type_id . '.view',
'_access_content_translation_manage' => 'create',
],
[
'parameters' => [
'source' => [
'type' => 'language',
],
'target' => [
'type' => 'language',
],
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
'load_latest_revision' => $load_latest_revision,
],
],
'_admin_route' => $is_admin,
]
);
$collection->add("entity.$entity_type_id.content_translation_add", $route);
}
if ($entity_type->hasLinkTemplate('drupal:content-translation-edit')) {
$route = new Route(
$entity_type->getLinkTemplate('drupal:content-translation-edit'),
[
'_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::edit',
'language' => NULL,
'_title' => 'Edit',
'entity_type_id' => $entity_type_id,
],
[
'_access_content_translation_manage' => 'update',
],
[
'parameters' => [
'language' => [
'type' => 'language',
],
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
'load_latest_revision' => $load_latest_revision,
],
],
'_admin_route' => $is_admin,
]
);
$collection->add("entity.$entity_type_id.content_translation_edit", $route);
}
if ($entity_type->hasLinkTemplate('drupal:content-translation-delete')) {
$route = new Route(
$entity_type->getLinkTemplate('drupal:content-translation-delete'),
[
'_entity_form' => $entity_type_id . '.content_translation_deletion',
'language' => NULL,
'_title' => 'Delete',
'entity_type_id' => $entity_type_id,
],
[
'_access_content_translation_manage' => 'delete',
],
[
'parameters' => [
'language' => [
'type' => 'language',
],
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
'load_latest_revision' => $load_latest_revision,
],
],
'_admin_route' => $is_admin,
]
);
$collection->add("entity.$entity_type_id.content_translation_delete", $route);
}
// Add our custom translation deletion access checker.
if ($load_latest_revision) {
@@ -249,7 +249,7 @@ class ContentTranslationSyncUnitTest extends KernelTestBase {
for ($delta = 0; $delta < $this->cardinality; $delta++) {
foreach ($this->columns as $column) {
// If the column is synchronized, the value should have been synced,
// for unsychronized columns, the value must not change.
// for unsynchronized columns, the value must not change.
$expected_value = in_array($column, $this->synchronized) ? $changed_items[$delta][$column] : $this->unchangedFieldValues[$langcode][$delta][$column];
$this->assertEqual($field_values[$langcode][$delta][$column], $expected_value, "Differing Item $delta column $column for langcode $langcode synced correctly");
}