From a07a5ee0f01c92617ad866e87b4295efbc4032f1 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 11 Sep 2012 14:17:20 -0400 Subject: [PATCH] Give Solr connection access to the service locator. --- .../VuFind/src/VuFind/Connection/Manager.php | 3 ++ module/VuFind/src/VuFind/Connection/Solr.php | 40 ++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/module/VuFind/src/VuFind/Connection/Manager.php b/module/VuFind/src/VuFind/Connection/Manager.php index cdd6d0b3559..eb6ebb92b01 100644 --- a/module/VuFind/src/VuFind/Connection/Manager.php +++ b/module/VuFind/src/VuFind/Connection/Manager.php @@ -113,6 +113,9 @@ class Manager $index = new $class($url, $core); } + // Set the service locator: + $index->setServiceLocator(self::$serviceLocator); + return $index; } } diff --git a/module/VuFind/src/VuFind/Connection/Solr.php b/module/VuFind/src/VuFind/Connection/Solr.php index 91d26d79cab..ee6c424465c 100644 --- a/module/VuFind/src/VuFind/Connection/Solr.php +++ b/module/VuFind/src/VuFind/Connection/Solr.php @@ -29,10 +29,10 @@ namespace VuFind\Connection; use VuFind\Config\Reader as ConfigReader, VuFind\Db\Table\ChangeTracker as ChangeTrackerTable, - VuFind\Exception\Solr as SolrException, - VuFind\Http\Client as HttpClient, - VuFind\Log\Logger, - VuFind\Solr\Utils as SolrUtils; + VuFind\Exception\Solr as SolrException, VuFind\Http\Client as HttpClient, + VuFind\Log\Logger, VuFind\Solr\Utils as SolrUtils, + Zend\ServiceManager\ServiceLocatorAwareInterface, + Zend\ServiceManager\ServiceLocatorInterface; /** * Solr HTTP Interface @@ -43,7 +43,7 @@ use VuFind\Config\Reader as ConfigReader, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/system_classes#index_interface Wiki */ -class Solr +class Solr implements ServiceLocatorAwareInterface { /** * A boolean value determining whether to print debug information @@ -128,6 +128,13 @@ class Solr */ protected $solrSearchParams; + /** + * Service locator + * + * @var ServiceLocatorInterface + */ + protected $serviceLocator; + /** * Constructor * @@ -1712,4 +1719,27 @@ class Solr $config = ConfigReader::getConfig(); return isset($config->Index->timeout) ? $config->Index->timeout : 30; } + + /** + * Set the service locator. + * + * @param ServiceLocatorInterface $serviceLocator Locator to register + * + * @return Solr + */ + public function setServiceLocator(ServiceLocatorInterface $serviceLocator) + { + $this->serviceLocator = $serviceLocator; + return $this; + } + + /** + * Get the service locator. + * + * @return \Zend\ServiceManager\ServiceLocatorInterface + */ + public function getServiceLocator() + { + return $this->serviceLocator; + } } \ No newline at end of file -- GitLab