function apachesolr_index_config_form_submit in Apache Solr Search 8
Same name and namespace in other branches
- 6.3 apachesolr.admin.inc \apachesolr_index_config_form_submit()
- 7 apachesolr.admin.inc \apachesolr_index_config_form_submit()
Submit handler for the bundle configuration form.
_state
Parameters
array $form:
File
- ./
apachesolr.admin.inc, line 1307 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_index_config_form_submit(array $form, array &$form_state) {
module_load_include('inc', 'apachesolr', 'apachesolr.index');
$form_values = $form_state['values'];
$env_id = $form_values['env_id'];
foreach ($form_values['entities'] as $entity_type => $bundles) {
$existing_bundles = apachesolr_get_index_bundles($env_id, $entity_type);
$all_bundles = array_keys($bundles);
$new_bundles = array_values(array_filter($bundles));
apachesolr_index_set_bundles($env_id, $entity_type, $new_bundles);
// Remove all excluded bundles - this happens on form submit
// even if there is no change so the admin can remove
// bundles if there was an error.
$excluded_bundles = array_diff($all_bundles, $new_bundles);
if (apachesolr_index_delete_bundles($env_id, $entity_type, $excluded_bundles)) {
$callback = apachesolr_entity_get_callback($entity_type, 'bundles changed callback');
if (!empty($callback)) {
call_user_func($callback, $env_id, $existing_bundles, $new_bundles);
}
}
else {
drupal_set_message(t('Search is temporarily unavailable. If the problem persists, please contact the site administrator.'), 'error');
}
}
// Clear the entity cache, since we will be changing its data.
entity_info_cache_clear();
cache_clear_all('apachesolr:environments', 'cache_apachesolr');
drupal_set_message(t('Your settings have been saved.'));
}