You are here

function apachesolr_get_solr in Apache Solr Search 6

Same name and namespace in other branches
  1. 8 apachesolr.module \apachesolr_get_solr()
  2. 5.2 apachesolr.module \apachesolr_get_solr()
  3. 5 apachesolr.module \apachesolr_get_solr()
  4. 6.3 apachesolr.module \apachesolr_get_solr()
  5. 6.2 apachesolr.module \apachesolr_get_solr()
  6. 7 apachesolr.module \apachesolr_get_solr()

Factory method for solr singleton object. Structure allows for an arbitrary number of solr objects to be used based on the host, port, path combination. Get an instance like this: $solr = apachesolr_get_solr();

Throws

Exception

22 calls to apachesolr_get_solr()
apachesolr_clear_cache in ./apachesolr.module
A wrapper for cache_clear_all to be used as a submit handler on forms that require clearing Luke cache etc.
apachesolr_config_file in ./apachesolr.admin.inc
Page callback to show one conf file.
apachesolr_config_files_overview in ./apachesolr.admin.inc
Page callback to show available conf files.
apachesolr_cron in ./apachesolr.module
Implementation of hook_cron().
apachesolr_delete_index in ./apachesolr.admin.inc
Utility function to delete the index and reset all index counters.

... See full list

File

./apachesolr.module, line 1311
Integration with the Apache Solr search application.

Code

function apachesolr_get_solr($host = NULL, $port = NULL, $path = NULL) {
  static $solr_cache;
  if (empty($host)) {
    $host = variable_get('apachesolr_host', 'localhost');
  }
  if (empty($port)) {
    $port = variable_get('apachesolr_port', '8983');
  }
  if (empty($path)) {
    $path = variable_get('apachesolr_path', '/solr');
  }
  if (empty($solr_cache[$host][$port][$path])) {
    list($module, $filepath, $class) = variable_get('apachesolr_service_class', array(
      'apachesolr',
      'Drupal_Apache_Solr_Service.php',
      'Drupal_Apache_Solr_Service',
    ));
    include_once drupal_get_path('module', $module) . '/' . $filepath;
    $solr = new $class($host, $port, $path);
    $solr_cache[$host][$port][$path] = $solr;
  }
  return $solr_cache[$host][$port][$path];
}