function Role::prepareRow

Same name in this branch
  1. 10 core/modules/user/src/Plugin/migrate/source/d7/Role.php \Drupal\user\Plugin\migrate\source\d7\Role::prepareRow()
Same name in other branches
  1. 9 core/modules/user/src/Plugin/migrate/source/d6/Role.php \Drupal\user\Plugin\migrate\source\d6\Role::prepareRow()
  2. 9 core/modules/user/src/Plugin/migrate/source/d7/Role.php \Drupal\user\Plugin\migrate\source\d7\Role::prepareRow()
  3. 8.9.x core/modules/user/src/Plugin/migrate/source/d6/Role.php \Drupal\user\Plugin\migrate\source\d6\Role::prepareRow()
  4. 8.9.x core/modules/user/src/Plugin/migrate/source/d7/Role.php \Drupal\user\Plugin\migrate\source\d7\Role::prepareRow()
  5. 11.x core/modules/user/src/Plugin/migrate/source/d6/Role.php \Drupal\user\Plugin\migrate\source\d6\Role::prepareRow()
  6. 11.x core/modules/user/src/Plugin/migrate/source/d7/Role.php \Drupal\user\Plugin\migrate\source\d7\Role::prepareRow()

Overrides SourcePluginBase::prepareRow

File

core/modules/user/src/Plugin/migrate/source/d6/Role.php, line 71

Class

Role
Drupal 6 role source from database.

Namespace

Drupal\user\Plugin\migrate\source\d6

Code

public function prepareRow(Row $row) {
    $rid = $row->getSourceProperty('rid');
    $permissions = $this->select('permission', 'p')
        ->fields('p', [
        'perm',
    ])
        ->condition('rid', $rid)
        ->execute()
        ->fetchField();
    // If a role has no permissions then set to an empty array. The role will
    // be migrated and given the default D8 permissions.
    if ($permissions) {
        $row->setSourceProperty('permissions', explode(', ', $permissions));
    }
    else {
        $row->setSourceProperty('permissions', []);
    }
    if (isset($this->filterPermissions[$rid])) {
        $row->setSourceProperty("filter_permissions:{$rid}", $this->filterPermissions[$rid]);
    }
    return parent::prepareRow($row);
}

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