3 namespace Drupal\user\Plugin\migrate\source\d7;
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
9 * Provides Drupal 7 user entity translations source plugin.
12 * id = "d7_user_entity_translation",
13 * source_module = "entity_translation"
16 class UserEntityTranslation extends FieldableEntity {
21 public function query() {
22 $query = $this->select('entity_translation', 'et')
24 ->condition('et.entity_type', 'user')
25 ->condition('et.source', '', '<>');
33 public function prepareRow(Row $row) {
34 $uid = $row->getSourceProperty('entity_id');
35 $language = $row->getSourceProperty('language');
37 // Get Field API field values.
38 foreach ($this->getFields('user') as $field_name => $field) {
39 // Ensure we're using the right language if the entity is translatable.
40 $field_language = $field['translatable'] ? $language : NULL;
41 $row->setSourceProperty($field_name, $this->getFieldValues('user', $field_name, $uid, NULL, $field_language));
44 return parent::prepareRow($row);
50 public function fields() {
52 'entity_type' => $this->t('The entity type this translation relates to'),
53 'entity_id' => $this->t('The entity id this translation relates to'),
54 'revision_id' => $this->t('The entity revision id this translation relates to'),
55 'language' => $this->t('The target language for this translation.'),
56 'source' => $this->t('The source language from which this translation was created.'),
57 'uid' => $this->t('The author of this translation.'),
58 'status' => $this->t('Boolean indicating whether the translation is published (visible to non-administrators).'),
59 'translate' => $this->t('A boolean indicating whether this translation needs to be updated.'),
60 'created' => $this->t('The Unix timestamp when the translation was created.'),
61 'changed' => $this->t('The Unix timestamp when the translation was most recently saved.'),
68 public function getIds() {