Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. User.php

function User::prepareRow

Same name in this branch
  1. 11.1.x 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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal