You are here

public function ProfileFieldValues::fields in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldValues.php \Drupal\user\Plugin\migrate\source\d6\ProfileFieldValues::fields()

Returns available fields on the source.

Return value

array Available fields in the source, keys are the field machine names as used in field mappings, values are descriptions.

Overrides MigrateSourceInterface::fields

File

core/modules/user/src/Plugin/migrate/source/d6/ProfileFieldValues.php, line 63

Class

ProfileFieldValues
Drupal 6 profile fields values source.

Namespace

Drupal\user\Plugin\migrate\source\d6

Code

public function fields() {
  $fields = [
    'fid' => $this
      ->t('Unique profile field ID.'),
    'uid' => $this
      ->t('The user Id.'),
    'value' => $this
      ->t('The value for this field.'),
  ];
  $query = $this
    ->select('profile_values', 'pv')
    ->fields('pv', [
    'fid',
    'value',
  ]);
  $query
    ->leftJoin('profile_fields', 'pf', 'pf.fid=pv.fid');
  $query
    ->fields('pf', [
    'name',
    'title',
  ]);
  $results = $query
    ->execute();
  foreach ($results as $profile) {
    $fields[$profile['name']] = $this
      ->t($profile['title']);
  }
  return $fields;
}