class Role

Same name in this branch
  1. 9 core/modules/user/src/Entity/Role.php \Drupal\user\Entity\Role
  2. 9 core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role
  3. 9 core/modules/user/src/Plugin/migrate/source/d6/Role.php \Drupal\user\Plugin\migrate\source\d6\Role
Same name and namespace in other branches
  1. 11.x core/modules/user/src/Entity/Role.php \Drupal\user\Entity\Role
  2. 11.x core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role
  3. 11.x core/modules/user/src/Plugin/migrate/source/d6/Role.php \Drupal\user\Plugin\migrate\source\d6\Role
  4. 11.x core/modules/user/src/Plugin/migrate/source/d7/Role.php \Drupal\user\Plugin\migrate\source\d7\Role

Drupal 7 role source from database.

For available configuration keys, refer to the parent classes.

Plugin annotation


@MigrateSource(
  id = "d7_user_role",
  source_module = "user"
)

Hierarchy

Expanded class hierarchy of Role

See also

\Drupal\migrate\Plugin\migrate\source\SqlBase

\Drupal\migrate\Plugin\migrate\source\SourcePluginBase

34 string references to 'Role'
Block::query in core/modules/block/src/Plugin/migrate/source/Block.php
ChangeUserRoleBase::buildConfigurationForm in core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php
drupal6.php in core/modules/migrate_drupal/tests/fixtures/drupal6.php
A database agnostic dump for testing purposes.
drupal6.php in core/modules/aggregator/tests/fixtures/drupal6.php
A database agnostic dump for testing purposes.
drupal7.php in core/modules/rdf/tests/fixtures/drupal7.php
A database agnostic dump for testing purposes.

... See full list

File

core/modules/user/src/Plugin/migrate/source/d7/Role.php, line 21

Namespace

Drupal\user\Plugin\migrate\source\d7
View source
class Role extends DrupalSqlBase {
  
  /**
   * {@inheritdoc}
   */
  public function query() {
    return $this->select('role', 'r')
      ->fields('r');
  }
  
  /**
   * {@inheritdoc}
   */
  public function fields() {
    return [
      'rid' => $this->t('Role ID.'),
      'name' => $this->t('The name of the user role.'),
      'weight' => $this->t('The weight of the role.'),
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    $permissions = $this->select('role_permission', 'rp')
      ->fields('rp', [
      'permission',
    ])
      ->condition('rid', $row->getSourceProperty('rid'))
      ->execute()
      ->fetchCol();
    $row->setSourceProperty('permissions', $permissions);
    return parent::prepareRow($row);
  }
  
  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids['rid']['type'] = 'integer';
    return $ids;
  }

}

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