You are here

public function DrupalVersion::getProfileValues in Drupal-to-Drupal data migration 7.2

Get any core profile values associated with this user.

Parameters

$row:

$entity_id:

2 calls to DrupalVersion::getProfileValues()
DrupalVersion5::getProfileValues in d5/d5.inc
Get any core profile values associated with this user.
DrupalVersion6::getProfileValues in d6/d6.inc
Get any core profile values associated with this user.
3 methods override DrupalVersion::getProfileValues()
DrupalVersion5::getProfileValues in d5/d5.inc
Get any core profile values associated with this user.
DrupalVersion6::getProfileValues in d6/d6.inc
Get any core profile values associated with this user.
DrupalVersion7::getProfileValues in d7/d7.inc
Get any core profile values associated with this user.

File

./migrate_d2d.migrate.inc, line 349
Base classes for all Drupal-to-Drupal migration classes.

Class

DrupalVersion
There should be an implementation of this abstract class, named DrupalVersion{version #}, for each Drupal version supported as a source. It will implement any functions needed by multiple version-specific classes (e.g., nodes as well as users).

Code

public function getProfileValues($row, $entity_id) {
  $query = Database::getConnection('default', $this->arguments['source_connection'])
    ->select('profile_values', 'v')
    ->fields('v', array(
    'value',
  ))
    ->condition('uid', $entity_id)
    ->condition('value', '', '<>');
  $query
    ->innerJoin('profile_fields', 'f', 'v.fid=f.fid');
  $query
    ->fields('f', array(
    'name',
    'type',
  ));
  $result = $query
    ->execute();
  foreach ($result as $data_row) {
    switch ($data_row->type) {
      case 'checkbox':
        switch (trim(strtolower($data_row->value))) {
          case 'n':
            $data_row->value = 0;
            break;
          case 'y':
            $data_row->value = 1;
            break;
          default:
            break;
        }
        break;
      case 'date':

        // Dates may be serialized arrays or NULLs.
        if (strpos($data_row->value, 'a:') === 0) {
          $date_array = unserialize($data_row->value);
          $data_row->value = $date_array['year'] . '-' . $date_array['month'] . '-' . $date_array['day'];
        }
        elseif (strpos($data_row->value, 'N;') === 0) {
          $data_row->value = NULL;
        }
        break;
    }
    $row->{$data_row->name} = $data_row->value;
  }
  return $row;
}