You are here

public function ElasticsearchViewsQuery::buildOptionsForm in Elasticsearch Connector 8.2

Same name and namespace in other branches
  1. 8.7 modules/elasticsearch_connector_views/src/Plugin/views/query/ElasticsearchViewsQuery.php \Drupal\elasticsearch_connector_views\Plugin\views\query\ElasticsearchViewsQuery::buildOptionsForm()
  2. 8.5 modules/elasticsearch_connector_views/src/Plugin/views/query/ElasticsearchViewsQuery.php \Drupal\elasticsearch_connector_views\Plugin\views\query\ElasticsearchViewsQuery::buildOptionsForm()
  3. 8.6 modules/elasticsearch_connector_views/src/Plugin/views/query/ElasticsearchViewsQuery.php \Drupal\elasticsearch_connector_views\Plugin\views\query\ElasticsearchViewsQuery::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides PluginBase::buildOptionsForm

File

modules/elasticsearch_connector_views/src/Plugin/views/query/ElasticsearchViewsQuery.php, line 226

Class

ElasticsearchViewsQuery
Defines a Views query class for searching on Search API indexes.

Namespace

Drupal\elasticsearch_connector_views\Plugin\views\query

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['bypass_access'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Bypass access checks'),
    '#description' => $this
      ->t('If the underlying search index has access checks enabled (e.g., through the "Content access" processor), this option allows you to disable them for this view. This will never disable any filters placed on this view.'),
    '#default_value' => $this->options['bypass_access'],
  );
  if ($this
    ->getEntityTypes(TRUE)) {
    $form['skip_access'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Skip entity access checks'),
      '#description' => $this
        ->t("By default, an additional access check will be executed for each entity returned by the search query. However, since removing results this way will break paging and result counts, it is preferable to configure the view in a way that it will only return accessible results. If you are sure that only accessible results will be returned in the search, or if you want to show results to which the user normally wouldn't have access, you can enable this option to skip those additional access checks. This should be used with care."),
      '#default_value' => $this->options['skip_access'],
      '#weight' => -1,
    );
    $form['bypass_access']['#states']['visible'][':input[name="query[options][skip_access]"]']['checked'] = TRUE;
  }

  // @todo Move this setting to the argument and filter plugins where it makes
  //   more sense for users.
  $form['parse_mode'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Parse mode'),
    '#description' => $this
      ->t('Choose how the search keys will be parsed.'),
    '#options' => array(),
    '#default_value' => $this->options['parse_mode'],
  );

  //    foreach ($this->query->parseModes() as $key => $mode) {
  //      $form['parse_mode']['#options'][$key] = $mode['name'];
  //      if (!empty($mode['description'])) {
  //        $states['visible'][':input[name="query[options][parse_mode]"]']['value'] = $key;
  //        $form["parse_mode_{$key}_description"] = array(
  //          '#type' => 'item',
  //          '#title' => $mode['name'],
  //          '#description' => $mode['description'],
  //          '#states' => $states,
  //        );
  //      }
  //    }
}