diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 470ccdd390ab95c66e99612152bf38fdbf8613fc..a88ed1a28bad43fa0a024f6708673a094ce70861 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -75,9 +75,15 @@ $config = array( ), 'auth_plugin_manager' => array( 'abstract_factories' => array('VuFind\Auth\PluginFactory'), + 'factories' => array( + 'ils' => function ($sm) { + return new \VuFind\Auth\ILS( + $sm->getServiceLocator()->get('ILSConnection') + ); + }, + ), 'invokables' => array( 'database' => 'VuFind\Auth\Database', - 'ils' => 'VuFind\Auth\ILS', 'ldap' => 'VuFind\Auth\LDAP', 'multiauth' => 'VuFind\Auth\MultiAuth', 'shibboleth' => 'VuFind\Auth\Shibboleth', diff --git a/module/VuFind/src/VuFind/Auth/ILS.php b/module/VuFind/src/VuFind/Auth/ILS.php index 4affd198983ceb6948d81c02a22f681aacd23a47..79e5dc139b643c1991bdf0ec6a64bcf8553f3f89 100644 --- a/module/VuFind/src/VuFind/Auth/ILS.php +++ b/module/VuFind/src/VuFind/Auth/ILS.php @@ -43,6 +43,16 @@ class ILS extends AbstractBase { protected $catalog = null; + /** + * Set the ILS connection for this object. + * + * @param \VuFind\ILS\Connection $connection ILS connection to set + */ + public function __construct(\VuFind\ILS\Connection $connection) + { + $this->setCatalog($connection); + } + /** * Get the ILS driver associated with this object (or load the default from * the service manager. @@ -51,23 +61,19 @@ class ILS extends AbstractBase */ public function getCatalog() { - if (null === $this->catalog) { - $this->catalog = $this->getServiceLocator()->getServiceLocator() - ->get('ILSConnection'); - } return $this->catalog; } /** - * Set the ILS driver associated with this object. + * Set the ILS connection for this object. * - * @param \VuFind\ILS\Driver\DriverInterface $driver Driver to set + * @param \VuFind\ILS\Connection $connection ILS connection to set * * @return void */ - public function setCatalog(\VuFind\ILS\Driver\DriverInterface $driver) + public function setCatalog(\VuFind\ILS\Connection $connection) { - $this->catalog = $driver; + $this->catalog = $connection; } /** diff --git a/module/VuFind/src/VuFindTest/Unit/TestCase.php b/module/VuFind/src/VuFindTest/Unit/TestCase.php index d533f805ea4fed4e5c528b79b7ff56bec6831438..48f64697de84261b911d43f7bbc052eb54c8a1c8 100644 --- a/module/VuFind/src/VuFindTest/Unit/TestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/TestCase.php @@ -151,7 +151,14 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase new \Zend\ServiceManager\Config( array( 'abstract_factories' => - array('VuFind\Auth\PluginFactory') + array('VuFind\Auth\PluginFactory'), + 'factories' => array( + 'ils' => function ($sm) { + return new \VuFind\Auth\ILS( + new \VuFind\ILS\Connection() + ); + }, + ), ) ) ); diff --git a/module/VuFind/tests/unit-tests/src/Auth/ILSTest.php b/module/VuFind/tests/unit-tests/src/Auth/ILSTest.php index 0f5274b1772bf3317d463cf47ccaa4061393a68d..986daf535e7a85998fcfd379a5d6337b412f2ea0 100644 --- a/module/VuFind/tests/unit-tests/src/Auth/ILSTest.php +++ b/module/VuFind/tests/unit-tests/src/Auth/ILSTest.php @@ -49,7 +49,7 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase { $this->driver = $this->getMock('VuFind\ILS\Driver\Demo'); $this->auth = $this->getAuthManager()->get('ILS'); - $this->auth->setCatalog($this->driver); + $this->auth->getCatalog()->setDriver($this->driver);; } /**