You are here

class MigrateFileFieldHandler in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 plugins/destinations/fields.inc \MigrateFileFieldHandler

Handle for file fields.

Hierarchy

Expanded class hierarchy of MigrateFileFieldHandler

1 string reference to 'MigrateFileFieldHandler'
migrate_migrate_api in ./migrate.migrate.inc

File

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

View source
class MigrateFileFieldHandler extends MigrateFileFieldBaseHandler {
  public function __construct() {
    $this
      ->registerTypes(array(
      'file',
    ));
  }

  /**
   * Implementation of MigrateFieldHandler::fields().
   * Note that file and image fields support slightly different field lists.
   *
   * @param $type
   *  The file field type - 'file' or 'image'
   * @param $instance
   *  Instance info for the field.
   * @param Migration $migration
   *  The migration context for the parent field. We can look at the mappings
   *  and determine which subfields are relevant.
   *
   * @return array
   */
  public function fields($type, $instance, $migration = NULL) {
    $fields = parent::fields($type, $instance, $migration);
    $fields += array(
      'description' => t('Subfield: <a href="@doc">String to be used as the description value</a>', array(
        '@doc' => 'http://drupal.org/node/1224042#description',
      )),
      'display' => t('Subfield: <a href="@doc">String to be used as the display value</a>', array(
        '@doc' => 'http://drupal.org/node/1224042#display',
      )),
    );
    return $fields;
  }

  /**
   * Implementation of MigrateFileFieldBaseHandler::buildFieldArray().
   */
  protected function buildFieldArray($field_array, $arguments, $delta) {
    if (isset($arguments['description'])) {
      if (is_array($arguments['description'])) {
        $field_array['description'] = $arguments['description'][$delta];
      }
      else {
        $field_array['description'] = $arguments['description'];
      }
    }
    else {
      $field_array['description'] = '';
    }
    if (isset($arguments['display'])) {
      if (is_array($arguments['display'])) {
        $field_array['display'] = $arguments['display'][$delta];
      }
      else {
        $field_array['display'] = $arguments['display'];
      }
    }
    else {
      $field_array['display'] = 1;
    }
    return $field_array;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MigrateFieldHandler::getFieldLanguage function Determine the language of the field.
MigrateFileFieldBaseHandler::destinationDir protected function Determine where the migrated file should go.
MigrateFileFieldBaseHandler::prepare public function Implementation of MigrateFieldHandler::prepare().
MigrateFileFieldHandler::buildFieldArray protected function Implementation of MigrateFileFieldBaseHandler::buildFieldArray(). Overrides MigrateFileFieldBaseHandler::buildFieldArray
MigrateFileFieldHandler::fields public function Implementation of MigrateFieldHandler::fields(). Note that file and image fields support slightly different field lists. Overrides MigrateFileFieldBaseHandler::fields
MigrateFileFieldHandler::__construct public function Overrides MigrateHandler::__construct
MigrateHandler::$dependencies protected property List of other handler classes which should be invoked before the current one.
MigrateHandler::$typesHandled protected property List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc.
MigrateHandler::getDependencies public function
MigrateHandler::getTypesHandled public function
MigrateHandler::handlesType public function Does this handler handle the given type? 1
MigrateHandler::registerTypes protected function Register a list of types handled by this class