3 namespace Drupal\permissions_by_term\Form;
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 class SettingsForm extends ConfigFormBase {
14 public function getFormId() {
15 return 'permissions_by_term_settings';
21 protected function getEditableConfigNames() {
23 'permissions_by_term.settings'
30 public function buildForm(array $form, FormStateInterface $form_state) {
31 $form = parent::buildForm($form, $form_state);
33 By default users are granted access content, as long they have access to a <strong>single</strong>
34 related taxonomy term. If the single term restriction option is checked, they must
35 have access to <strong>all</strong> related taxonomy terms to access an node.
38 $form['single_term_restriction'] = [
39 '#type' => 'checkbox',
40 '#title' => t('Single Term Restriction'),
41 '#description' => t($description),
42 '#default_value' => \Drupal::config('permissions_by_term.settings.single_term_restriction')->get('value'),
45 return parent::buildForm($form, $form_state);
51 public function submitForm(array &$form, FormStateInterface $form_state) {
52 \Drupal::configFactory()
53 ->getEditable('permissions_by_term.settings.single_term_restriction')
54 ->set('value', $form_state->getValue('single_term_restriction'))
57 node_access_rebuild(true);
59 parent::submitForm($form, $form_state);