You are here

protected function Role::initializeIterator in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Plugin/migrate/source/d6/Role.php \Drupal\user\Plugin\migrate\source\d6\Role::initializeIterator()

Implementation of MigrateSource::performRewind().

We could simply execute the query and be functionally correct, but we will take advantage of the PDO-based API to optimize the query up-front.

Overrides SqlBase::initializeIterator

File

core/modules/user/src/Plugin/migrate/source/d6/Role.php, line 52
Contains \Drupal\user\Plugin\migrate\source\d6\Role.

Class

Role
Drupal 6 role source from database.

Namespace

Drupal\user\Plugin\migrate\source\d6

Code

protected function initializeIterator() {
  $filter_roles = $this
    ->select('filter_formats', 'f')
    ->fields('f', array(
    'format',
    'roles',
  ))
    ->execute()
    ->fetchAllKeyed();
  foreach ($filter_roles as $format => $roles) {

    // Drupal 6 code: $roles = ','. implode(',', $roles) .',';
    // Remove the beginning and ending comma.
    foreach (explode(',', trim($roles, ',')) as $rid) {
      $this->filterPermissions[$rid][] = $format;
    }
  }
  return parent::initializeIterator();
}