You are here

public function User::prepareRow in Drupal 10

Same name in this branch
  1. 10 core/modules/user/src/Plugin/migrate/source/d6/User.php \Drupal\user\Plugin\migrate\source\d6\User::prepareRow()
  2. 10 core/modules/user/src/Plugin/migrate/source/d7/User.php \Drupal\user\Plugin\migrate\source\d7\User::prepareRow()
Same name and namespace in other branches
  1. 8 core/modules/user/src/Plugin/migrate/source/d6/User.php \Drupal\user\Plugin\migrate\source\d6\User::prepareRow()
  2. 9 core/modules/user/src/Plugin/migrate/source/d6/User.php \Drupal\user\Plugin\migrate\source\d6\User::prepareRow()

Adds additional data to the row.

Parameters

\Drupal\migrate\Row $row: The row object.

Return value

bool FALSE if this row needs to be skipped.

Overrides SourcePluginBase::prepareRow

File

core/modules/user/src/Plugin/migrate/source/d6/User.php, line 47

Class

User
Drupal 6 user source from database.

Namespace

Drupal\user\Plugin\migrate\source\d6

Code

public function prepareRow(Row $row) {

  // User roles.
  $roles = $this
    ->select('users_roles', 'ur')
    ->fields('ur', [
    'rid',
  ])
    ->condition('ur.uid', $row
    ->getSourceProperty('uid'))
    ->execute()
    ->fetchCol();
  $row
    ->setSourceProperty('roles', $roles);

  // We are adding here the Event contributed module column.
  // @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
  if ($row
    ->hasSourceProperty('timezone_id') && $row
    ->getSourceProperty('timezone_id')) {
    if ($this
      ->getDatabase()
      ->schema()
      ->tableExists('event_timezones')) {
      $event_timezone = $this
        ->select('event_timezones', 'e')
        ->fields('e', [
        'name',
      ])
        ->condition('e.timezone', $row
        ->getSourceProperty('timezone_id'))
        ->execute()
        ->fetchField();
      if ($event_timezone) {
        $row
          ->setSourceProperty('event_timezone', $event_timezone);
      }
    }
  }

  // Unserialize Data.
  $data = $row
    ->getSourceProperty('data');
  if ($data !== NULL) {
    $row
      ->setSourceProperty('data', unserialize($row
      ->getSourceProperty('data')));
  }
  return parent::prepareRow($row);
}