You are here

public function SettingsForm::buildForm in Permissions by Term 8.2

Same name and namespace in other branches
  1. 8 src/Form/SettingsForm.php \Drupal\permissions_by_term\Form\SettingsForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/SettingsForm.php, line 48

Class

SettingsForm

Namespace

Drupal\permissions_by_term\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $form['require_all_terms_granted'] = [
    '#type' => 'checkbox',
    '#title' => t('Require all terms granted'),
    '#description' => t('By default users are granted access content, as long they have access to a <strong>single</strong>
related taxonomy term. If the <strong>require all terms granted</strong> option is checked, they must
have access to <strong>all</strong> related taxonomy terms to access an node.'),
    '#default_value' => \Drupal::config('permissions_by_term.settings')
      ->get('require_all_terms_granted'),
  ];
  $form['permission_mode'] = [
    '#type' => 'checkbox',
    '#title' => t('Permission mode'),
    '#description' => t('This mode makes nodes accessible (view and edit) only, if editors have been explicitly granted the permission to them. Users won\'t have access to nodes matching any of the following conditions:
<br />- nodes without any terms
<br />- nodes without any terms which grant them permission'),
    '#default_value' => \Drupal::config('permissions_by_term.settings')
      ->get('permission_mode'),
  ];
  $form['disable_node_access_records'] = [
    '#type' => 'checkbox',
    '#title' => t('Disable node access records'),
    '#description' => t('By disabling node access records, nodes won\'t be hidden in:
<br />- listings made by the Views module (e.g. search result pages)
<br />- menus
<br />- other Drupal core systems, which are based on <a href="https://www.drupal.org/docs/8/modules/permissions-by-term#s-node-access-records" target="_blank" title="Node Access records documentation">Node Access records</a><br />
This setting can be useful, if you just want to restrict nodes on node view and
node edit. Like hiding unpublished nodes from editors during a content
moderation workflow. Disabling node access records will save you some time on
node save and taxonomy save, since the node access records must not be rebuild. Also it will provide major performance
benefit on large, non-cached content listings like the "/admin/content" page. If you want to restrict nodes on your
overall website and you are using a warmed page cache, then it is recommended to leave this setting disabled.'),
    '#default_value' => \Drupal::config('permissions_by_term.settings')
      ->get('disable_node_access_records'),
  ];
  $form['target_bundles'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Limit by taxonomy vocabularies'),
    '#description' => $this
      ->t('Whether to limit permissions management and search by selected taxonomy vocabularies. If left empty, all taxonomy vocabularies are allowed.'),
    '#options' => $this
      ->getTaxonomyVocabularyOptions(),
    '#default_value' => $this
      ->config('permissions_by_term.settings')
      ->get('target_bundles') ?? [],
  ];
  return parent::buildForm($form, $form_state);
}