You are here

protected function DrupalVersion5::profileFields in Drupal-to-Drupal data migration 7.2

Retrieve any user profile fields from the core profile module or content_profile.

Return value

array

1 call to DrupalVersion5::profileFields()
DrupalVersion5::populateSourceFieldInfo in d5/d5.inc
Retrieve info on all fields attached to the given entity type and bundle. Populates $this->sourceFieldInfo.

File

d5/d5.inc, line 304
Implementation of DrupalVersion for Drupal 5 sources.

Class

DrupalVersion5
Drupal 5 implementations of functions shared among multiple types of objects.

Code

protected function profileFields() {
  migrate_instrument_start('DrupalVersion5::profileFields');

  // Get any content_profile node types. A variable named content_profile_use_foo
  // with a serialized value of 1 means foo is a node type of interest.
  $names = Database::getConnection('default', $this->arguments['source_connection'])
    ->select('variable', 'v')
    ->fields('v', array(
    'name',
  ))
    ->condition('name', 'content_profile_use_%', 'LIKE')
    ->condition('value', 'i:1;')
    ->execute()
    ->fetchCol();
  $index = strlen('content_profile_use_');
  foreach ($names as $name) {
    $type_name = substr($name, $index);
    $this->profileTypes[] = $type_name;

    // Populates sourceFieldInfo directly
    $this
      ->populateSourceFieldInfo('node', $type_name);
  }

  // Then, check the core profile
  if (Database::getConnection('default', $this->arguments['source_connection'])
    ->schema()
    ->tableExists('profile_fields')) {
    $query = Database::getConnection('default', $this->arguments['source_connection'])
      ->select('profile_fields', 'f')
      ->fields('f', array(
      'title',
      'name',
      'type',
    ));
    $result = $query
      ->execute();
    foreach ($result as $row) {
      $this->sourceFieldInfo[trim($row->name)] = array(
        'label' => $row->title,
        'type' => $row->type,
      );
    }
  }
  migrate_instrument_stop('DrupalVersion5::profileFields');
}