class DomainUserHandler in Domain Access 7.3
Migration class for supporting Drupal user accounts.
In our migration class, you may add a domain_user field mapping. This field may contain a domain_id string or array of domain ids (either numeric or machine_name, and you may mix the two).
If you fail to set domain_user, the user will be assigned to the default domain, if it exists.
Hierarchy
- class \MigrateHandler
- class \MigrateDestinationHandler
- class \DomainUserHandler
- class \MigrateDestinationHandler
Expanded class hierarchy of DomainUserHandler
1 string reference to 'DomainUserHandler'
File
- ./
domain.migrate.inc, line 298 - Support for domains in core Drupal objects
View source
class DomainUserHandler extends MigrateDestinationHandler {
public function __construct() {
$this
->registerTypes(array(
'user',
));
}
public function fields() {
$fields = array(
'domain_user' => t('Domain: assigned domains'),
);
return $fields;
}
public function prepare($user, stdClass $row) {
// If set, ensure domains exist.
$domains = array();
if (isset($user->uid)) {
domain_user_set($user);
}
if (isset($user->domain_user)) {
$user->domain_user = (array) $user->domain_user;
foreach ($user->domain_user as $id) {
if ($domain = domain_load($id)) {
$domains[$domain['domain_id']] = $domain['domain_id'];
}
if ($domain = domain_machine_name_load($id)) {
$domains[$domain['domain_id']] = $domain['domain_id'];
}
}
}
// If empty, assign to the default domain.
if (empty($domains) && ($default = domain_default_id())) {
$domains[$default] = $default;
}
$user->domain_user = $domains;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DomainUserHandler:: |
public | function | ||
DomainUserHandler:: |
public | function | ||
DomainUserHandler:: |
public | function |
Overrides MigrateHandler:: |
|
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? | 1 |
MigrateHandler:: |
protected | function | Register a list of types handled by this class |