You are here

class MigrateProfileUserHandler in Migrate 6.2

Destination class handling profile.module data.

Hierarchy

Expanded class hierarchy of MigrateProfileUserHandler

1 string reference to 'MigrateProfileUserHandler'
migrate_migrate_api in ./migrate.module

File

plugins/destinations/profile.inc, line 12
Support for profile.module fields as a destination.

View source
class MigrateProfileUserHandler extends MigrateDestinationHandler {
  public function __construct() {
    $this
      ->registerTypes(array(
      'user',
    ));
  }

  /**
   * Returns a list of fields available to be mapped for users.
   *
   * @return array
   *  Keys: machine names of the fields (to be passed to addFieldMapping)
   *  Values: Human-friendly descriptions of the fields.
   */
  public function fields() {
    $fields = array();
    if (module_exists('profile')) {
      foreach (profile_categories() as $category) {
        $result = _profile_get_fields($category['name'], FALSE);
        while ($field = db_fetch_object($result)) {
          $fields[$field->name] = $field->category . ': ' . $field->title;
        }
      }
    }
    return $fields;
  }
  public function prepare(stdClass $account, stdClass $row) {
    if (module_exists('profile')) {
      static $fields;
      if (!isset($fields)) {
        $fields = array();
        foreach (profile_categories() as $category) {
          $result = _profile_get_fields($category['name'], FALSE);
          while ($field = db_fetch_object($result)) {
            $fields[$field->name] = $field;
          }
        }
      }
      foreach ($fields as $key => $field) {
        if (isset($account->{$key})) {
          switch ($field->type) {
            case 'date':
              $timestamp = MigrationBase::timestamp($account->{$key});
              $account->{$key} = array(
                'month' => date('n', $timestamp),
                'day' => date('j', $timestamp),
                'year' => date('Y', $timestamp),
              );
              break;
            default:
          }
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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?
MigrateHandler::registerTypes protected function Register a list of types handled by this class
MigrateProfileUserHandler::fields public function Returns a list of fields available to be mapped for users.
MigrateProfileUserHandler::prepare public function
MigrateProfileUserHandler::__construct public function Overrides MigrateHandler::__construct