Skip to content
Snippets Groups Projects
Commit 90d06686 authored by Demian Katz's avatar Demian Katz
Browse files

Use explicit dependency injection for ILS authentication module instead of...

Use explicit dependency injection for ILS authentication module instead of relying on service locator.
parent 9e0a6bc1
No related merge requests found
...@@ -75,9 +75,15 @@ $config = array( ...@@ -75,9 +75,15 @@ $config = array(
), ),
'auth_plugin_manager' => array( 'auth_plugin_manager' => array(
'abstract_factories' => array('VuFind\Auth\PluginFactory'), 'abstract_factories' => array('VuFind\Auth\PluginFactory'),
'factories' => array(
'ils' => function ($sm) {
return new \VuFind\Auth\ILS(
$sm->getServiceLocator()->get('ILSConnection')
);
},
),
'invokables' => array( 'invokables' => array(
'database' => 'VuFind\Auth\Database', 'database' => 'VuFind\Auth\Database',
'ils' => 'VuFind\Auth\ILS',
'ldap' => 'VuFind\Auth\LDAP', 'ldap' => 'VuFind\Auth\LDAP',
'multiauth' => 'VuFind\Auth\MultiAuth', 'multiauth' => 'VuFind\Auth\MultiAuth',
'shibboleth' => 'VuFind\Auth\Shibboleth', 'shibboleth' => 'VuFind\Auth\Shibboleth',
......
...@@ -43,6 +43,16 @@ class ILS extends AbstractBase ...@@ -43,6 +43,16 @@ class ILS extends AbstractBase
{ {
protected $catalog = null; 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 * Get the ILS driver associated with this object (or load the default from
* the service manager. * the service manager.
...@@ -51,23 +61,19 @@ class ILS extends AbstractBase ...@@ -51,23 +61,19 @@ class ILS extends AbstractBase
*/ */
public function getCatalog() public function getCatalog()
{ {
if (null === $this->catalog) {
$this->catalog = $this->getServiceLocator()->getServiceLocator()
->get('ILSConnection');
}
return $this->catalog; 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 * @return void
*/ */
public function setCatalog(\VuFind\ILS\Driver\DriverInterface $driver) public function setCatalog(\VuFind\ILS\Connection $connection)
{ {
$this->catalog = $driver; $this->catalog = $connection;
} }
/** /**
......
...@@ -151,7 +151,14 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase ...@@ -151,7 +151,14 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
new \Zend\ServiceManager\Config( new \Zend\ServiceManager\Config(
array( array(
'abstract_factories' => 'abstract_factories' =>
array('VuFind\Auth\PluginFactory') array('VuFind\Auth\PluginFactory'),
'factories' => array(
'ils' => function ($sm) {
return new \VuFind\Auth\ILS(
new \VuFind\ILS\Connection()
);
},
),
) )
) )
); );
......
...@@ -49,7 +49,7 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase ...@@ -49,7 +49,7 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase
{ {
$this->driver = $this->getMock('VuFind\ILS\Driver\Demo'); $this->driver = $this->getMock('VuFind\ILS\Driver\Demo');
$this->auth = $this->getAuthManager()->get('ILS'); $this->auth = $this->getAuthManager()->get('ILS');
$this->auth->setCatalog($this->driver); $this->auth->getCatalog()->setDriver($this->driver);;
} }
/** /**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment