protected function D7Webform::buildAccessTable in Webform: Migrate 8
Same name and namespace in other branches
- 8.2 src/Plugin/migrate/source/d7/D7Webform.php \Drupal\webform_migrate\Plugin\migrate\source\d7\D7Webform::buildAccessTable()
Build access table from webform roles table.
1 call to D7Webform::buildAccessTable()
- D7Webform::prepareRow in src/
Plugin/ migrate/ source/ d7/ D7Webform.php - Adds additional data to the row.
File
- src/
Plugin/ migrate/ source/ d7/ D7Webform.php, line 784
Class
- D7Webform
- Drupal 7 webform source from database.
Namespace
Drupal\webform_migrate\Plugin\migrate\source\d7Code
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;
}