You are here

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

@abstract Return the names and labels of all custom fields (CCK pre-D7, core fields D7 and later) attached to the given entity type and bundle.

Parameters

$entity_type: Type of entity ('node', 'user', etc.) for which to retrieve field info.

$bundle: Bundle within the entity type (e.g., 'article', 'blog', etc.).

$include_body: Treat a node body as if it were a custom field (for supporting content_profile).

Return value

array An array keyed by field name, with field labels as the values.

File

./migrate_d2d.migrate.inc, line 323
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 getSourceFields($entity_type, $bundle, $include_body = FALSE) {
  $this
    ->populateSourceFieldInfo($entity_type, $bundle);
  $fields = array();
  foreach ($this->sourceFieldInfo as $field_name => $info) {
    $fields[$field_name] = $info['label'];
    $i = 0;
    if (isset($info['columns'])) {
      foreach ($info['columns'] as $display_name => $column_name) {

        // We skip the first column, which we've covered with the field name
        // itself.
        if ($i > 0) {
          $fields[$display_name] = t('!label subfield', array(
            '!label' => $info['label'],
          ));
        }
        $i++;
      }
    }
  }
  return $fields;
}