You are here

public function SearchApiAcquiaSearchService::configurationForm in Acquia Search for Search API 7.2

Same name and namespace in other branches
  1. 7 includes/SearchApiAcquiaSearchService.php \SearchApiAcquiaSearchService::configurationForm()

Overrides SearchApiSolrService::configurationForm().

Populates the Solr configs with Acquia Search Information.

Overrides SearchApiSolrService::configurationForm

File

includes/SearchApiAcquiaSearchService.php, line 133
Contains SearchApiAcquiaSearchService.

Class

SearchApiAcquiaSearchService
Search API service class for Acquia Search.

Code

public function configurationForm(array $form, array &$form_state) {
  $form = parent::configurationForm($form, $form_state);

  // Set our special overrides if applicable
  $this
    ->setConnectionOptions();
  $options = $this->options += array(
    'edismax' => 0,
    'modify_acquia_connection' => FALSE,
    'scheme' => 'https',
    'acquia_search_api_version' => self::ACQUIA_SEARCH_API_V2,
  );

  // HTTP authentication is not needed since Acquia Search uses an HMAC
  // authentication mechanism.
  $form['http']['#access'] = FALSE;

  // Port should always force 443.
  $form['scheme'] = array(
    '#type' => 'value',
    '#value' => '443',
  );

  // Scheme should always force https.
  $form['scheme'] = array(
    '#type' => 'value',
    '#value' => 'https',
  );

  // Hiding to not make this form too confusing.
  $form['advanced']['solr_version']['#access'] = FALSE;
  $form['edismax'] = array(
    '#type' => 'checkbox',
    '#title' => t('Always allow advanced syntax for Acquia Search'),
    '#default_value' => $options['edismax'],
    '#description' => t('If enabled, all Acquia Search keyword searches may use advanced <a href="@url">Lucene syntax</a> such as wildcard searches, fuzzy searches, proximity searches, boolean operators and more via the Extended Dismax parser. If not enabled, this syntax wll only be used when needed to enable wildcard searches.', array(
      '@url' => 'http://lucene.apache.org/java/2_9_3/queryparsersyntax.html',
    )),
    '#weight' => -30,
  );
  $form['modify_acquia_connection'] = array(
    '#type' => 'checkbox',
    '#title' => 'Modify Acquia Search Connection Parameters',
    '#default_value' => $options['modify_acquia_connection'],
    '#description' => t('Only check this box if you are absolutely certain about what you are doing. Any misconfigurations will most likely break your site\'s connection to Acquia Search.'),
    '#weight' => -20,
  );
  $form['acquia_search_api_version'] = array(
    '#type' => 'select',
    '#options' => array(
      self::ACQUIA_SEARCH_API_V2 => 'Solr 6 and below',
      self::ACQUIA_SEARCH_API_V3 => 'Solr 7 and above',
    ),
    '#title' => 'Acquia Search Solr version',
    '#default_value' => $options['acquia_search_api_version'],
    '#description' => t('Only change this if you are absolutely certain about what you are doing. Any misconfigurations will most likely break your site\'s connection to Acquia Search.'),
    '#weight' => -10,
  );
  $form['clean_ids_form']['#weight'] = 10;

  // Re-sets defaults with Acquia information.
  $form['host']['#default_value'] = $options['host'];
  $form['path']['#default_value'] = $options['path'];

  // Only display fields if we are modifying the connection parameters to the
  // Acquia Search service.
  $states = array(
    'visible' => array(
      ':input[name="options[form][modify_acquia_connection]"]' => array(
        'checked' => TRUE,
      ),
    ),
  );
  $form['host']['#states'] = $states;
  $form['path']['#states'] = $states;
  $form['port']['#states'] = $states;

  // We cannot connect directly to the Solr instance, so don't make it a link.
  if (isset($form['server_description'])) {
    $status_message = search_api_acquia_get_search_status_message($this->server);
    $form['server_description'] = array(
      '#type' => 'item',
      '#title' => t('Acquia Search status for this connection'),
      '#description' => $status_message,
      '#weight' => -40,
    );
  }
  return $form;
}