function User::prepareRow

Same name in this branch
  1. 11.x core/modules/user/src/Plugin/migrate/source/d7/User.php \Drupal\user\Plugin\migrate\source\d7\User::prepareRow()
Same name in other branches
  1. 9 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/d7/User.php \Drupal\user\Plugin\migrate\source\d7\User::prepareRow()
  3. 8.9.x core/modules/user/src/Plugin/migrate/source/d6/User.php \Drupal\user\Plugin\migrate\source\d6\User::prepareRow()
  4. 8.9.x core/modules/user/src/Plugin/migrate/source/d7/User.php \Drupal\user\Plugin\migrate\source\d7\User::prepareRow()
  5. 10 core/modules/user/src/Plugin/migrate/source/d6/User.php \Drupal\user\Plugin\migrate\source\d6\User::prepareRow()
  6. 10 core/modules/user/src/Plugin/migrate/source/d7/User.php \Drupal\user\Plugin\migrate\source\d7\User::prepareRow()

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.