You are here

protected function D6Webform::buildAccessTable in Webform: Migrate 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/migrate/source/d6/D6Webform.php \Drupal\webform_migrate\Plugin\migrate\source\d6\D6Webform::buildAccessTable()

Build access table from webform roles table.

1 call to D6Webform::buildAccessTable()
D6Webform::prepareRow in src/Plugin/migrate/source/d6/D6Webform.php
Adds additional data to the row.

File

src/Plugin/migrate/source/d6/D6Webform.php, line 520

Class

D6Webform
Drupal 6 webform source from database.

Namespace

Drupal\webform_migrate\Plugin\migrate\source\d6

Code

protected function buildAccessTable($nid) {
  $query = $this
    ->select('webform_roles', 'wr');
  $query
    ->innerJoin('role', 'r', 'wr.rid=r.rid');
  $query
    ->fields('wr', [
    'nid',
    'rid',
  ])
    ->fields('r', [
    'name',
  ]);
  $wf_roles = $query
    ->condition('nid', $nid)
    ->execute();
  $roles = [];

  // Handle rids 1 and 2 as per user_update_8002.
  $map = [
    1 => 'anonymous',
    2 => 'authenticated',
  ];
  foreach ($wf_roles as $role) {
    if (isset($map[$role['rid']])) {
      $roles[] = $map[$role['rid']];
    }
    else {
      $roles[] = str_replace(' ', '_', strtolower($role['name']));
    }
  }
  $access = [
    'create' => [
      'roles' => $roles,
      'users' => [],
    ],
  ];
  return $access;
}