diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 17fc6ecc2787b464ab196ec254d8e2afa768c3ca..0ef73c0bcf1d618a0d1e8b637f918937a4c353ce 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -486,6 +486,11 @@ $config = array( $sm->getServiceLocator()->get('VuFind\Config') ); }, + 'noils' => function ($sm) { + return new \VuFind\ILS\Driver\NoILS( + $sm->getServiceLocator()->get('VuFind\RecordLoader') + ); + }, 'unicorn' => function ($sm) { return new \VuFind\ILS\Driver\Unicorn( $sm->getServiceLocator()->get('VuFind\DateConverter') @@ -511,7 +516,6 @@ $config = array( 'innovative' => 'VuFind\ILS\Driver\Innovative', 'koha' => 'VuFind\ILS\Driver\Koha', 'newgenlib' => 'VuFind\ILS\Driver\NewGenLib', - 'noils' => 'VuFind\ILS\Driver\NoILS', 'pica' => 'VuFind\ILS\Driver\PICA', 'sample' => 'VuFind\ILS\Driver\Sample', 'symphony' => 'VuFind\ILS\Driver\Symphony', diff --git a/module/VuFind/src/VuFind/ILS/Driver/NoILS.php b/module/VuFind/src/VuFind/ILS/Driver/NoILS.php index 7f8513da55e1166bd779b9be273e82b34c552ae3..70492f0bbb636c7f9f938e4c8fc0e4745ab33b81 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/NoILS.php +++ b/module/VuFind/src/VuFind/ILS/Driver/NoILS.php @@ -28,9 +28,7 @@ */ namespace VuFind\ILS\Driver; use VuFind\Exception\ILS as ILSException, - VuFind\I18n\Translator\TranslatorAwareInterface, - Zend\ServiceManager\ServiceLocatorAwareInterface, - Zend\ServiceManager\ServiceLocatorInterface; + VuFind\I18n\Translator\TranslatorAwareInterface; /** * Driver for offline/missing ILS. @@ -42,22 +40,31 @@ use VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/vufind2:building_an_ils_driver Wiki */ -class NoILS extends AbstractBase implements ServiceLocatorAwareInterface, - TranslatorAwareInterface +class NoILS extends AbstractBase implements TranslatorAwareInterface { /** - * Service locator + * Translator (or null if unavailable) * - * @var ServiceLocatorInterface + * @var \Zend\I18n\Translator\Translator */ - protected $serviceLocator; + protected $translator = null; /** - * Translator (or null if unavailable) + * Record loader * - * @var \Zend\I18n\Translator\Translator + * @var \VuFind\Record\Loader */ - protected $translator = null; + protected $recordLoader; + + /** + * Constructor + * + * @param \VuFind\Record\Loader $loader Record loader + */ + public function __construct(\VuFind\Record\Loader $loader) + { + $this->recordLoader = $loader; + } /** * Initialize the driver. @@ -95,8 +102,7 @@ class NoILS extends AbstractBase implements ServiceLocatorAwareInterface, */ public function getSolrRecord($id) { - return $this->getServiceLocator()->getServiceLocator() - ->get('VuFind\RecordLoader')->load($id); + return $this->recordLoader->load($id); } /** @@ -347,29 +353,6 @@ class NoILS extends AbstractBase implements ServiceLocatorAwareInterface, return null; } - /** - * Set the service locator. - * - * @param ServiceLocatorInterface $serviceLocator Locator to register - * - * @return NoILS - */ - public function setServiceLocator(ServiceLocatorInterface $serviceLocator) - { - $this->serviceLocator = $serviceLocator; - return $this; - } - - /** - * Get the service locator. - * - * @return \Zend\ServiceManager\ServiceLocatorInterface - */ - public function getServiceLocator() - { - return $this->serviceLocator; - } - /** * Set a translator * diff --git a/module/VuFind/tests/unit-tests/src/ILS/Driver/NoILSTest.php b/module/VuFind/tests/unit-tests/src/ILS/Driver/NoILSTest.php index 62d376fe651250a5757a45620fcc9e7de0ef55f5..9650243315002f0feb8eb6af5e47113c51c4bad0 100644 --- a/module/VuFind/tests/unit-tests/src/ILS/Driver/NoILSTest.php +++ b/module/VuFind/tests/unit-tests/src/ILS/Driver/NoILSTest.php @@ -39,6 +39,18 @@ use VuFind\ILS\Driver\NoILS; */ class NoILSTest extends \VuFindTest\Unit\TestCase { + /** + * Mock record loader + * + * @param \VuFind\Record\Loader + */ + protected $loader; + + /** + * Driver object + * + * @var NoILS + */ protected $driver; /** @@ -46,7 +58,14 @@ class NoILSTest extends \VuFindTest\Unit\TestCase */ public function __construct() { - $this->driver = new NoILS(); + $this->loader = $this->getMock( + 'VuFind\Record\Loader', array(), + array( + $this->getMock('VuFindSearch\Service'), + $this->getMock('VuFind\RecordDriver\PluginManager') + ) + ); + $this->driver = new NoILS($this->loader); $this->driver->init(); }