You are here

function search_config_node_settings in Search configuration 8

Same name and namespace in other branches
  1. 7 search_config.module \search_config_node_settings()

Helper function to get the settings.

4 calls to search_config_node_settings()
search_config_form_search_admin_settings_alter in ./search_config.module
Implements hook_form_FORM_alter()
search_config_form_search_form_alter in ./search_config.module
Implements of hook_form_FORM_alter().
search_config_query_node_access_alter in ./search_config.module
Implements of hook_query_node_access_alter().
_search_config_advanced_form in ./search_config.node.inc
This function implements the options to configure the default Drupal search form, including type filter, field visibility, form visibility, etc.

File

./search_config.module, line 594
The module that search form, including enforcing search restrictions by content type.

Code

function search_config_node_settings() {
  $search_config_settings = \Drupal::config('search_config.settings');
  $settings['forms'] = [
    'toggle_forms' => 0,
    // Show adv if both forms are present
    'move_keyword_search' => 0,
    // Move keyword search into adv form
    'advanced_populate' => 0,
    // Try and repopulate the adv form
    'advanced_expand' => 'default',
    // Control the presentation of adv form
    // Controls all 3 'Containing...' fields.
    'remove_containing_wrapper' => 'default',
  ];
  $settings['fields'] = [
    'containing_any' => [],
    'containing_phrase' => [],
    'containing_none' => [],
    'types' => [],
    'category' => [],
    'language' => [],
  ];
  $settings['results'] = [
    'limit' => '10',
  ];
  $settings['restrictions'] = [
    'admin_bypass' => 1,
    'remove_advanced' => 0,
  ];
  foreach ($settings['fields'] as $field => $info) {
    $settings['fields'][$field] = [
      'remove' => 0,
      // Hides the field
      'roles' => [],
    ];
    if ($field == 'types') {
      $settings['fields'][$field] = [
        'filter' => [],
        // Content type to HIDE
        'groupings' => [],
      ];
    }

    // @todo: What features do we need here?
    if ($field == 'category') {
      $settings['fields'][$field] = [
        'filter' => [],
        // Vocabs to HIDE
        'widget' => 'textfield',
      ];
    }
  }
  return $settings;
}