You are here

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

Same name and namespace in other branches
  1. 8.3 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.

File

src/Form/SearchApiFederatedSolrSearchAppSettingsForm.php, line 256
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);
  $is_site_name_property = $index_config
    ->get('field_settings.site_name.configuration.site_name') ? 'true' : '';
  $elem = [
    '#type' => 'hidden',
    '#name' => 'site_name_property',
    '#value' => $is_site_name_property,
    '#attributes' => [
      'id' => [
        'site-name-property',
      ],
    ],
  ];
  return $elem;
}