public function DrupalUserMigration::__construct in Drupal-to-Drupal data migration 7.2
Parameters
array $arguments: picture_migration - Machine name of a picture migration, used to establish dependencies and a sourceMigration for the picture mapping. role_migration - Machine name of a role migration, used to establish dependencies and a sourceMigration for the picture mapping.
Overrides DrupalMigration::__construct
3 calls to DrupalUserMigration::__construct()
- DrupalUser5Migration::__construct in d5/
user.inc - DrupalUser6Migration::__construct in d6/
user.inc - DrupalUser7Migration::__construct in d7/
user.inc - Required arguments:
3 methods override DrupalUserMigration::__construct()
- DrupalUser5Migration::__construct in d5/
user.inc - DrupalUser6Migration::__construct in d6/
user.inc - DrupalUser7Migration::__construct in d7/
user.inc - Required arguments:
File
- ./
user.inc, line 35 - Base class for migrating users into Drupal.
Class
- DrupalUserMigration
- Base class for all user migrations - handles commonalities across all supported source Drupal versions.
Code
public function __construct(array $arguments) {
parent::__construct($arguments);
if (!empty($arguments['picture_migration'])) {
$this->pictureMigration = $arguments['picture_migration'];
$this->dependencies[] = $this->pictureMigration;
}
if (!empty($arguments['role_migration'])) {
$this->roleMigration = $arguments['role_migration'];
$this->dependencies[] = $this->roleMigration;
}
// Document known core fields
$this->sourceFields += array(
'uid' => t('User ID'),
'mail' => t('Email address'),
'name' => t('Username'),
'pass' => t('Password'),
'status' => t('Status'),
'created' => t('Registered timestamp'),
'access' => t('Last access timestamp'),
'login' => t('Last login timestamp'),
'picture' => t('Picture'),
'signature' => t('Signature'),
'signature_format' => t('Signature format'),
'timezone' => t('Timezone'),
'language' => t('Language'),
'theme' => t('Default theme'),
'init' => t('Init'),
'data' => t('Data'),
);
// Get any CCK fields attached to users.
$this->sourceFields += $this->version
->getSourceFields('user', 'user');
if ($this
->moduleExists('path')) {
$this->sourceFields['path'] = t('Path alias');
}
if ($this->roleMigration) {
$this->sourceFields['roles'] = t('Roles');
}
if (!isset($this->sourceOptions['track_changes']) && !$this->newOnly) {
$this->sourceOptions['track_changes'] = TRUE;
}
$this->source = new MigrateSourceSQL($this
->query(), $this->sourceFields, NULL, $this->sourceOptions);
$this->map = new MigrateSQLMap($this->machineName, array(
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Source user ID',
'alias' => 'u',
),
), DrupalDestinationUser::getKeySchema(), $this->mapConnection);
// Most mappings are straight-forward
$this
->addSimpleMappings(array(
'pass',
'mail',
'theme',
'signature',
'created',
'access',
'login',
'status',
'language',
'init',
'timezone',
));
// user_save() expects the data field to be unpacked
$this
->addFieldMapping('data', 'data')
->callbacks('unserialize');
// Dedupe username collisions by appending _1, _2, etc.
$this
->addFieldMapping('name', 'name')
->dedupe('users', 'name');
if (isset($this->pictureMigration)) {
$this
->addFieldMapping('picture', 'picture')
->sourceMigration($this->pictureMigration);
}
else {
$this
->addFieldMapping('picture', 'picture');
}
if (isset($this->roleMigration)) {
$this
->addFieldMapping('roles', 'roles')
->sourceMigration($this->roleMigration);
}
else {
$this
->addFieldMapping('roles');
}
$this
->addFieldMapping('signature_format', 'signature_format')
->callbacks(array(
$this,
'mapFormat',
));
$this
->addUnmigratedDestinations(array(
'is_new',
'role_names',
));
if (module_exists('path') && $this
->moduleExists('path')) {
$this
->addFieldMapping('path', 'path')
->description('Handled in prepareRow');
}
else {
if (module_exists('path')) {
$this
->addUnmigratedDestinations(array(
'path',
));
}
elseif ($this
->moduleExists('path')) {
$this
->addUnmigratedSources(array(
'path',
));
}
}
if (module_exists('pathauto')) {
$this
->addFieldMapping('pathauto')
->description('By default, disable in favor of migrated paths')
->defaultValue(0);
}
}