3 namespace Drupal\user\Plugin\migrate\source\d7;
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
9 * Drupal 7 role source from database.
12 * id = "d7_user_role",
13 * source_module = "user"
16 class Role extends DrupalSqlBase {
21 public function query() {
22 return $this->select('role', 'r')->fields('r');
28 public function fields() {
30 'rid' => $this->t('Role ID.'),
31 'name' => $this->t('The name of the user role.'),
32 'weight' => $this->t('The weight of the role.'),
39 public function prepareRow(Row $row) {
40 $permissions = $this->select('role_permission', 'rp')
41 ->fields('rp', ['permission'])
42 ->condition('rid', $row->getSourceProperty('rid'))
45 $row->setSourceProperty('permissions', $permissions);
47 return parent::prepareRow($row);
53 public function getIds() {
54 $ids['rid']['type'] = 'integer';