protected function WorkbenchAccessByUserForm::removeEditors in Workbench Access 8
Remove editors to the section.
Parameters
array $uids: User ids to add.
int $section_id: Workbench access section id.
array $existing_editors: Existing editors uids.
1 call to WorkbenchAccessByUserForm::removeEditors()
- WorkbenchAccessByUserForm::submitForm in src/
Form/ WorkbenchAccessByUserForm.php - Form submission handler.
File
- src/
Form/ WorkbenchAccessByUserForm.php, line 310
Class
- WorkbenchAccessByUserForm
- Configure Workbench Access per user.
Namespace
Drupal\workbench_access\FormCode
protected function removeEditors(array $uids, $section_id, array $existing_editors = []) {
$editors_removed = [];
/** @var \Drupal\user\UserInterface[] $users */
$users = User::loadMultiple($uids);
foreach ($users as $user_id => $user) {
if (isset($existing_editors[$user_id])) {
$this->userSectionStorage
->removeUser($this->scheme, $user, [
$section_id,
]);
$editors_removed[] = $existing_editors[$user_id];
}
}
if (count($editors_removed)) {
$text = $this
->formatPlural(count($editors_removed), 'User @user removed.', 'Users removed: @user', [
'@user' => implode(', ', $editors_removed),
]);
\Drupal::messenger()
->addMessage($text);
}
}