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 $config = $this->config('permissions_by_term.settings');
33 $form = parent::buildForm($form, $form_state);
36 By default users have granted access to an node, as long they have access to a <strong>single</strong>
37 related taxonomy term. If the single term restriction option is checked, they must
38 have access to <strong>all</strong> related taxonomy terms to access an node. Because as soon the
39 specific node is related to a "single" non-permitted taxonomy term, the access will
43 $form['single_term_restriction'] = [
44 '#type' => 'checkbox',
45 '#title' => t('Single Term Restriction'),
46 '#description' => t($description),
47 '#default_value' => \Drupal::config('permissions_by_term.settings.single_term_restriction')->get('value'),
50 return parent::buildForm($form, $form_state);
56 public function submitForm(array &$form, FormStateInterface $form_state) {
57 \Drupal::configFactory()
58 ->getEditable('permissions_by_term.settings.single_term_restriction')
59 ->set('value', $form_state->getValue('single_term_restriction'))
62 node_access_rebuild(true);
64 parent::submitForm($form, $form_state);