You are here

public function DrupalRoleMigration::prepare in Drupal-to-Drupal data migration 7.2

Apply any role mappings

Parameters

$row:

Return value

bool

File

./role.inc, line 71
Base class for migrating roles into Drupal.

Class

DrupalRoleMigration
Base class for all role migrations - handles commonalities across all supported source Drupal versions.

Code

public function prepare($role, $row) {
  if (isset($this->roleMappings[$role->name])) {
    $destination_name = $this->roleMappings[$role->name];
    $destination_rid = db_select('role', 'r')
      ->fields('r', array(
      'rid',
    ))
      ->condition('name', $destination_name)
      ->execute()
      ->fetchField();
    if ($destination_rid) {
      $role->rid = $destination_rid;

      // Make sure we don't change the destination name
      $role->name = $destination_name;
      $this->rollbackAction = MigrateMap::ROLLBACK_PRESERVE;
    }
  }
}