UserEntityTranslation.php in Drupal 10
File
core/modules/user/src/Plugin/migrate/source/d7/UserEntityTranslation.php
View source
<?php
namespace Drupal\user\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
class UserEntityTranslation extends FieldableEntity {
public function query() {
$query = $this
->select('entity_translation', 'et')
->fields('et')
->condition('et.entity_type', 'user')
->condition('et.source', '', '<>');
return $query;
}
public function prepareRow(Row $row) {
$uid = $row
->getSourceProperty('entity_id');
$language = $row
->getSourceProperty('language');
foreach ($this
->getFields('user') as $field_name => $field) {
$field_language = $field['translatable'] ? $language : NULL;
$row
->setSourceProperty($field_name, $this
->getFieldValues('user', $field_name, $uid, NULL, $field_language));
}
return parent::prepareRow($row);
}
public function fields() {
return [
'entity_type' => $this
->t('The entity type this translation relates to'),
'entity_id' => $this
->t('The entity id this translation relates to'),
'revision_id' => $this
->t('The entity revision id this translation relates to'),
'language' => $this
->t('The target language for this translation.'),
'source' => $this
->t('The source language from which this translation was created.'),
'uid' => $this
->t('The author of this translation.'),
'status' => $this
->t('Boolean indicating whether the translation is published (visible to non-administrators).'),
'translate' => $this
->t('A boolean indicating whether this translation needs to be updated.'),
'created' => $this
->t('The Unix timestamp when the translation was created.'),
'changed' => $this
->t('The Unix timestamp when the translation was most recently saved.'),
];
}
public function getIds() {
return [
'entity_id' => [
'type' => 'integer',
],
'language' => [
'type' => 'string',
],
];
}
}