/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['search_api_bypass_access'] = array('#type' => 'checkbox', '#title' => $this->t('Bypass access checks'), '#description' => $this->t('If the underlying search index has access checks enabled, this option allows you to disable them for this view.'), '#default_value' => $this->options['search_api_bypass_access']); if ($this->getEntityTypes(TRUE)) { $form['entity_access'] = array('#type' => 'checkbox', '#title' => $this->t('Additional access checks on result entities'), '#description' => $this->t("Execute an access check for all result entities. This prevents users from seeing inappropriate content when the index contains stale data, or doesn't provide access checks. However, result counts, paging and other things won't work correctly if results are eliminated in this way, so only use this as a last ressort (and in addition to other checks, if possible)."), '#default_value' => $this->options['entity_access']); } // @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); } } }
/** * {@inheritdoc} */ 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); } } }