function apachesolr_environment_save in Apache Solr Search 8
Same name and namespace in other branches
- 6.3 apachesolr.module \apachesolr_environment_save()
- 7 apachesolr.module \apachesolr_environment_save()
Function that saves an environment
Parameters
$environment: The environment it needs to save.
9 calls to apachesolr_environment_save()
- AbstractDrupalSolrOnlineWebTestCase::setUpSolr in tests/
solr_index_and_search.test - apachesolr_ctools_environment_save in ./
apachesolr.module - Callback for saving Apache Solr environment CTools exportables.
- apachesolr_drush_solr_set_env_url in drush/
apachesolr.drush.inc - Set the environment url based on the environment ID
- apachesolr_environment_clone in ./
apachesolr.module - Function that clones an environment
- apachesolr_environment_edit_submit in ./
apachesolr.admin.inc - Submit handler for the environment edit page
File
- ./
apachesolr.module, line 1353 - Integration with the Apache Solr search application.
Code
function apachesolr_environment_save($environment) {
module_load_include('inc', 'apachesolr', 'apachesolr.index');
$default = array(
'env_id' => '',
'name' => '',
'url' => '',
'service_class' => '',
);
$conf = isset($environment['conf']) ? $environment['conf'] : array();
$index_bundles = isset($environment['index_bundles']) ? $environment['index_bundles'] : array();
// Remove any unexpected fields.
// @todo - get this from the schema?.
$environment = array_intersect_key($environment, $default);
db_merge('apachesolr_environment')
->key(array(
'env_id' => $environment['env_id'],
))
->fields($environment)
->execute();
// Update the environment variables (if any).
foreach ($conf as $name => $value) {
db_merge('apachesolr_environment_variable')
->key(array(
'env_id' => $environment['env_id'],
'name' => $name,
))
->fields(array(
'value' => serialize($value),
))
->execute();
}
// Update the index bundles (if any).
foreach ($index_bundles as $entity_type => $bundles) {
apachesolr_index_set_bundles($environment['env_id'], $entity_type, $bundles);
}
apachesolr_environments_clear_cache();
}