class MigrateDestinationRole in Migrate 7.2
Same name and namespace in other branches
- 6.2 plugins/destinations/user.inc \MigrateDestinationRole
Hierarchy
- class \MigrateDestination
- class \MigrateDestinationTable
- class \MigrateDestinationRole
- class \MigrateDestinationTable
Expanded class hierarchy of MigrateDestinationRole
File
- plugins/
destinations/ user.inc, line 294 - Support for user destinations.
View source
class MigrateDestinationRole extends MigrateDestinationTable {
public function __construct() {
parent::__construct('role');
}
/**
* Get the key definition for the role table.
*
* @param $dummy
* PHP is picky - it throws E_STRICT notices if we don't have a parameter
* because MigrateDestinationTable has one.
*/
public static function getKeySchema($dummy = NULL) {
return MigrateDestinationTable::getKeySchema('role');
}
/**
* Delete a single row.
*
* @param $id
* Primary key values.
*/
public function rollback(array $id) {
migrate_instrument_start('role rollback');
$rid = reset($id);
user_role_delete((int) $rid);
migrate_instrument_stop('role rollback');
}
/**
* Import a single row.
*
* @param $entity
* Object object to build. Prefilled with any fields mapped in the Migration.
* @param $row
* Raw source data object - passed through to prepare/complete handlers.
*
* @return array
* Array of key fields of the object that was saved if
* successful. FALSE on failure.
*/
public function import(stdClass $entity, stdClass $row) {
$migration = Migration::currentMigration();
$updating = FALSE;
// Updating previously-migrated content?
if (isset($row->migrate_map_destid1)) {
$updating = TRUE;
if (isset($entity->rid)) {
if ($entity->rid != $row->migrate_map_destid1) {
throw new MigrateException(t("Incoming id !id and map destination id !destid don't match", array(
'!id' => $entity->rid,
'!destid' => $row->migrate_map_destid1,
)));
}
}
else {
$entity->rid = $row->migrate_map_destid1;
}
}
if ($migration
->getSystemOfRecord() == Migration::DESTINATION) {
$updating = TRUE;
if (!isset($entity->rid)) {
throw new MigrateException(t('System-of-record is DESTINATION, but no destination id provided'));
}
$old_entity = user_role_load($entity->rid);
foreach ($entity as $field => $value) {
$old_entity->{$field} = $entity->{$field};
}
$entity = $old_entity;
}
$this
->prepare($entity, $row);
user_role_save($entity);
$this
->complete($entity, $row);
if (!empty($entity->rid)) {
$id = array(
$entity->rid,
);
if ($updating) {
$this->numUpdated++;
}
else {
$this->numCreated++;
}
}
else {
$id = FALSE;
}
return $id;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateDestination:: |
protected | property | Maintain stats on the number of destination objects created or updated. | |
MigrateDestination:: |
protected | property | ||
MigrateDestination:: |
public | function | ||
MigrateDestination:: |
public | function | ||
MigrateDestination:: |
public | function | Reset numCreated and numUpdated back to 0. | |
MigrateDestinationRole:: |
public static | function |
Get the key definition for the role table. Overrides MigrateDestinationTable:: |
|
MigrateDestinationRole:: |
public | function |
Import a single row. Overrides MigrateDestinationTable:: |
|
MigrateDestinationRole:: |
public | function |
Delete a single row. Overrides MigrateDestinationTable:: |
|
MigrateDestinationRole:: |
public | function |
Null constructor Overrides MigrateDestinationTable:: |
|
MigrateDestinationTable:: |
protected | property | The schema of the current table. | |
MigrateDestinationTable:: |
protected | property | The name of the current table. | |
MigrateDestinationTable:: |
public | function | Give handlers a shot at modifying the object (or taking additional action) after saving it. | |
MigrateDestinationTable:: |
public | function | Give handlers a shot at cleaning up after a row has been rolled back. | |
MigrateDestinationTable:: |
public | function |
Returns a list of fields available to be mapped. Overrides MigrateDestination:: |
|
MigrateDestinationTable:: |
public | function | Give handlers a shot at modifying the object before saving it. | |
MigrateDestinationTable:: |
public | function | Give handlers a shot at cleaning up before the row has been rolled back. | |
MigrateDestinationTable:: |
public | function |
Derived classes must implement __toString(). Overrides MigrateDestination:: |