You are here

public function MigrateFileFieldBaseHandler::fields in Migrate 7.2

Implementation of MigrateFieldHandler::fields().

Parameters

$type: The file field type - 'file', 'image', etc.

$instance: Instance info for the field.

Migration $migration: The migration context for the parent field. We can look at the mappings and determine which subfields are relevant.

Return value

array

2 calls to MigrateFileFieldBaseHandler::fields()
MigrateFileFieldHandler::fields in plugins/destinations/fields.inc
Implementation of MigrateFieldHandler::fields(). Note that file and image fields support slightly different field lists.
MigrateImageFieldHandler::fields in plugins/destinations/fields.inc
Implementation of MigrateFieldHandler::fields(). Note that file and image fields support slightly different field lists.
2 methods override MigrateFileFieldBaseHandler::fields()
MigrateFileFieldHandler::fields in plugins/destinations/fields.inc
Implementation of MigrateFieldHandler::fields(). Note that file and image fields support slightly different field lists.
MigrateImageFieldHandler::fields in plugins/destinations/fields.inc
Implementation of MigrateFieldHandler::fields(). Note that file and image fields support slightly different field lists.

File

plugins/destinations/fields.inc, line 639
Support for processing entity fields

Class

MigrateFileFieldBaseHandler
The next generation of file field handler. This class focuses on the file field itself, and offloads understanding of obtaining the actual file and dealing with the file entity to an embedded MigrateFileInterface instance.

Code

public function fields($type, $instance, $migration = NULL) {
  $fields = array(
    'file_class' => t('Option: <a href="@doc">Implementation of MigrateFile to use</a>', array(
      '@doc' => 'http://drupal.org/node/1540106#file_class',
    )),
  );
  $field = field_info_field($instance['field_name']);
  if (field_is_translatable($instance['entity_type'], $field)) {
    $fields['language'] = t('Subfield: Language for the field');
  }

  // If we can identify the file class mapped to this field, pick up the
  // subfields specific to that class.
  if ($migration) {
    $field_mappings = $migration
      ->getFieldMappings();
    $class_mapping = $instance['field_name'] . ':file_class';
    if (isset($field_mappings[$class_mapping])) {
      $mapping = $field_mappings[$class_mapping];
      $file_class = $mapping
        ->getDefaultValue();
    }
  }
  if (empty($file_class)) {
    $file_class = 'MigrateFileUri';
  }
  $fields += call_user_func(array(
    $file_class,
    'fields',
  ));
  return $fields;
}