class MigrateProfileUserHandler in Migrate 6.2
Destination class handling profile.module data.
Hierarchy
- class \MigrateHandler
- class \MigrateDestinationHandler
- class \MigrateProfileUserHandler
- class \MigrateDestinationHandler
Expanded class hierarchy of MigrateProfileUserHandler
1 string reference to 'MigrateProfileUserHandler'
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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateHandler:: |
protected | property | List of other handler classes which should be invoked before the current one. | |
MigrateHandler:: |
protected | property | List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc. | |
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | Does this handler handle the given type? | |
MigrateHandler:: |
protected | function | Register a list of types handled by this class | |
MigrateProfileUserHandler:: |
public | function | Returns a list of fields available to be mapped for users. | |
MigrateProfileUserHandler:: |
public | function | ||
MigrateProfileUserHandler:: |
public | function |
Overrides MigrateHandler:: |