diff --git a/search_api_solr.install b/search_api_solr.install index 13cc897..a0a0147 100644 --- a/search_api_solr.install +++ b/search_api_solr.install @@ -7,7 +7,6 @@ function search_api_solr_requirements($phase) { if ($phase == 'install') { $t = get_t(); module_load_include('module', 'search_api_solr'); - spl_autoload_register('_search_api_solr_autoload'); if (class_exists('Apache_Solr_Service')) { $version = trim(Apache_Solr_Service::SVN_REVISION, '$ :A..Za..z'); if ($version < 59) { diff --git a/search_api_solr.module b/search_api_solr.module index 3097d13..633f379 100644 --- a/search_api_solr.module +++ b/search_api_solr.module @@ -5,13 +5,6 @@ */ /** - * Implements hook_init(). - */ -function search_api_solr_init() { - spl_autoload_register('_search_api_solr_autoload'); -} - -/** * Return path to SolrPhpClient library path, or FALSE if not found. */ function _search_api_solr_solrphpclient_path() { @@ -35,8 +28,8 @@ function _search_api_solr_solrphpclient_path() { } $search_dirs[] = drupal_get_path('module', 'search_api_solr') . '/SolrPhpClient'; foreach ($search_dirs as $dir) { - $dir = DRUPAL_ROOT . '/' . $dir; - if (is_dir($dir)) { + $dir = $dir; + if (is_dir(DRUPAL_ROOT . '/' . $dir)) { $path = $dir; break; } @@ -51,24 +44,32 @@ function _search_api_solr_solrphpclient_path() { } /** - * Autoloader for the SolrPhpClient classes. + * Implements hook_registry_files_alter(). + * + * Alter the registry of files to include all classes of solr php. */ -function _search_api_solr_autoload($name) { - static $lookup_cache = array(); - - if (isset($lookup_cache[$name])) { - return $lookup_cache[$name]; - } - elseif (substr($name, 0, 11) == 'Apache_Solr') { - $path = _search_api_solr_solrphpclient_path(); - if (file_exists($file_path = $path . '/' . str_replace('_', '/', $name) . '.php')) { - require_once $file_path; - $lookup_cache[$name] = TRUE; - return TRUE; - } +function search_api_solr_registry_files_alter(&$files, $indexed_modules) { + $path = _search_api_solr_solrphpclient_path(); + $solr_files = array( + '/InvalidArgumentException.php', + '/Exception.php', + '/NoServiceAvailableException.php', + '/Document.php', + '/Service.php', + '/Response.php', + '/Service/Balaner.php', + '/HttpTransport/CurlNoReuse.php', + '/HttpTransport/Interface.php', + '/HttpTransport/Curl.php', + '/HttpTransport/Abstract.php', + '/HttpTransport/Response.php', + '/HttpTransport/FileGetContents.php', + '/HttpTransportException.php', + '/ParserException.php' + ); + foreach ($solr_files as $file) { + $files[$path . '/Apache/Solr' . $file] = array('module' => 'search_api_solr', 'weight' => 0); } - $lookup_cache[$name] = FALSE; - return FALSE; } /**