public function ContentAccessPageForm::forcePermissions in Content Access 8
Checkboxes access for content.
Formapi #process callback, that disables checkboxes for roles without access to content.
File
- src/
Form/ ContentAccessPageForm.php, line 216
Class
- ContentAccessPageForm
- Node Access settings form.
Namespace
Drupal\content_access\FormCode
public function forcePermissions($element, FormStateInterface $form_state, &$complete_form) {
$storage = $form_state
->getStorage();
if (!empty($storage['node'] && is_array($element['#parents']))) {
$node = $storage['node'];
foreach (content_access_get_settings(reset($element['#parents']), $node
->getType()) as $rid) {
$element[$rid]['#disabled'] = TRUE;
$element[$rid]['#attributes']['disabled'] = 'disabled';
$element[$rid]['#value'] = TRUE;
$element[$rid]['#checked'] = TRUE;
$prefix_attr = new Attribute([
'title' => $this
->t("Permission is granted due to the content type\\'s access control settings."),
]);
$element[$rid]['#prefix'] = '<span ' . $prefix_attr . '>';
$element[$rid]['#suffix'] = "</span>";
}
}
return $element;
}