You are here

class MigrateImageFieldHandler in Migrate 7.2

Handle for image fields;

Hierarchy

Expanded class hierarchy of MigrateImageFieldHandler

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

File

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

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

  /**
   * 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(
      'alt' => t('Subfield: <a href="@doc">String to be used as the alt value</a>', array(
        '@doc' => 'http://drupal.org/node/1224042#alt',
      )),
      'title' => t('Subfield: <a href="@doc">String to be used as the title value</a>', array(
        '@doc' => 'http://drupal.org/node/1224042#title',
      )),
    );
    return $fields;
  }

  /**
   * Implementation of MigrateFileFieldBaseHandler::buildFieldArray().
   */
  protected function buildFieldArray($field_array, $arguments, $delta) {
    if (isset($arguments['alt'])) {
      if (is_array($arguments['alt'])) {
        $field_array['alt'] = $arguments['alt'][$delta];
      }
      else {
        $field_array['alt'] = $arguments['alt'];
      }
    }
    if (isset($arguments['title'])) {
      if (is_array($arguments['title'])) {
        $field_array['title'] = $arguments['title'][$delta];
      }
      else {
        $field_array['title'] = $arguments['title'];
      }
    }
    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().
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
MigrateImageFieldHandler::buildFieldArray protected function Implementation of MigrateFileFieldBaseHandler::buildFieldArray(). Overrides MigrateFileFieldBaseHandler::buildFieldArray
MigrateImageFieldHandler::fields public function Implementation of MigrateFieldHandler::fields(). Note that file and image fields support slightly different field lists. Overrides MigrateFileFieldBaseHandler::fields
MigrateImageFieldHandler::__construct public function Overrides MigrateHandler::__construct