You are here

public function SearchApiFederatedSolrSearchAppSettingsForm::getSiteName in Search API Federated Solr 8.3

Same name and namespace in other branches
  1. 8 src/Form/SearchApiFederatedSolrSearchAppSettingsForm.php \Drupal\search_api_federated_solr\Form\SearchApiFederatedSolrSearchAppSettingsForm::getSiteName()
  2. 8.2 src/Form/SearchApiFederatedSolrSearchAppSettingsForm.php \Drupal\search_api_federated_solr\Form\SearchApiFederatedSolrSearchAppSettingsForm::getSiteName()
  3. 4.x src/Form/SearchApiFederatedSolrSearchAppSettingsForm.php \Drupal\search_api_federated_solr\Form\SearchApiFederatedSolrSearchAppSettingsForm::getSiteName()

Get the name of the site.

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 $elem Hidden form element used to flag the state of the site name in the index.

File

src/Form/SearchApiFederatedSolrSearchAppSettingsForm.php, line 786
Contains \Drupal\search_api_solr_federated\Form\SearchApiFederatedSolrSearchAppSettingsForm.

Class

SearchApiFederatedSolrSearchAppSettingsForm
Class SearchApiFederatedSolrSearchAppSettingsForm.

Namespace

Drupal\search_api_federated_solr\Form

Code

public function getSiteName(array &$form, FormStateInterface $form_state) {

  // Get the id of the chosen index.
  $search_index = $form_state
    ->getValue('search_index');

  // Get the index configuration object.
  $index_config = \Drupal::config('search_api.index.' . $search_index);
  $site_name_property = $index_config
    ->get('field_settings.site_name.configuration.site_name');
  $use_system_site_name = $index_config
    ->get('field_settings.site_name.configuration.use_system_site_name');
  $is_site_name_property = $site_name_property !== '' || $use_system_site_name === 1 ? 'true' : '';
  $elem = [
    '#type' => 'hidden',
    '#name' => 'site_name_property',
    '#value' => $is_site_name_property,
    '#attributes' => [
      'id' => [
        'site-name-property',
      ],
    ],
  ];
  return $elem;
}