Code Coverage  | 
     ||||||||||
Classes and Traits  | 
      Functions and Methods  | 
      Lines  | 
     ||||||||
| Total |         | 
      100.00%  | 
      1 / 1  | 
              | 
      100.00%  | 
      3 / 3  | 
      CRAP |         | 
      100.00%  | 
      10 / 10  | 
     
| Role |         | 
      100.00%  | 
      1 / 1  | 
              | 
      100.00%  | 
      4 / 4  | 
      4 |         | 
      100.00%  | 
      10 / 10  | 
     
| query |         | 
      100.00%  | 
      1 / 1  | 
      1 |         | 
      100.00%  | 
      1 / 1  | 
     |||
| fields |         | 
      100.00%  | 
      1 / 1  | 
      1 |         | 
      100.00%  | 
      0 / 0  | 
     |||
| prepareRow |         | 
      100.00%  | 
      1 / 1  | 
      1 |         | 
      100.00%  | 
      7 / 7  | 
     |||
| getIds |         | 
      100.00%  | 
      1 / 1  | 
      1 |         | 
      100.00%  | 
      2 / 2  | 
     |||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\user\Plugin\migrate\source\d7\Role. | |
| */ | |
| namespace Drupal\user\Plugin\migrate\source\d7; | |
| use Drupal\migrate\Row; | |
| use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; | |
| /** | |
| * Drupal 7 role source from database. | |
| * | |
| * @MigrateSource( | |
| * id = "d7_user_role" | |
| * ) | |
| */ | |
| class Role extends DrupalSqlBase { | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function query() { | |
| return $this->select('role', 'r')->fields('r'); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function fields() { | |
| return array( | |
| '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; | |
| } | |
| } |