diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index ad00baea39aaa0a05b81763df6907dbe69ac960b..44f38d05fe6a494b6f13e9a748690601d7f73d7f 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -435,6 +435,7 @@ $config = [ 'noils' => 'VuFind\ILS\Driver\Factory::getNoILS', 'paia' => 'VuFind\ILS\Driver\Factory::getPAIA', 'kohailsdi' => 'VuFind\ILS\Driver\Factory::getKohaILSDI', + 'symphony' => 'VuFind\ILS\Driver\Factory::getSymphony', 'unicorn' => 'VuFind\ILS\Driver\Factory::getUnicorn', 'voyager' => 'VuFind\ILS\Driver\Factory::getVoyager', 'voyagerrestful' => 'VuFind\ILS\Driver\Factory::getVoyagerRestful', @@ -449,7 +450,6 @@ $config = [ 'polaris' => 'VuFind\ILS\Driver\Polaris', 'sample' => 'VuFind\ILS\Driver\Sample', 'sierra' => 'VuFind\ILS\Driver\Sierra', - 'symphony' => 'VuFind\ILS\Driver\Symphony', 'virtua' => 'VuFind\ILS\Driver\Virtua', 'xcncip2' => 'VuFind\ILS\Driver\XCNCIP2', ], diff --git a/module/VuFind/src/VuFind/ILS/Driver/Factory.php b/module/VuFind/src/VuFind/ILS/Driver/Factory.php index c028f544234aa3ad41951cd8362e0bbbab6a5b99..472f1cf3d2d776ab8c1b7c7ad148eac594f4ffa4 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Factory.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Factory.php @@ -196,6 +196,21 @@ class Factory return new KohaILSDI($sm->getServiceLocator()->get('VuFind\DateConverter')); } + /** + * Factory for Symphony driver. + * + * @param ServiceManager $sm Service manager. + * + * @return Symphony + */ + public static function getSymphony(ServiceManager $sm) + { + return new Symphony( + $sm->getServiceLocator()->get('VuFind\RecordLoader'), + $sm->getServiceLocator()->get('VuFind\CacheManager') + ); + } + /** * Factory for Unicorn driver. * diff --git a/module/VuFind/src/VuFind/ILS/Driver/Symphony.php b/module/VuFind/src/VuFind/ILS/Driver/Symphony.php index e34f7f06b7de727c846d89d2e8b98ba0575a7fb8..50235a8eba16e2a6c5c59868a728ea1ada6b1f5d 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Symphony.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Symphony.php @@ -27,9 +27,12 @@ * @link https://vufind.org/wiki/development:plugins:ils_drivers Wiki */ namespace VuFind\ILS\Driver; -use SoapClient, SoapFault, SoapHeader, VuFind\Exception\ILS as ILSException, - Zend\ServiceManager\ServiceLocatorAwareInterface, - Zend\ServiceManager\ServiceLocatorInterface; +use SoapClient; +use SoapFault; +use SoapHeader; +use VuFind\Cache\Manager as CacheManager; +use VuFind\Exception\ILS as ILSException; +use VuFind\Record\Loader; use Zend\Log\LoggerAwareInterface; /** @@ -42,11 +45,9 @@ use Zend\Log\LoggerAwareInterface; * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development:plugins:ils_drivers Wiki */ -class Symphony extends AbstractBase - implements ServiceLocatorAwareInterface, LoggerAwareInterface +class Symphony extends AbstractBase implements LoggerAwareInterface { use \VuFind\Log\LoggerAwareTrait; - use \Zend\ServiceManager\ServiceLocatorAwareTrait; /** * Cache for policy information @@ -62,6 +63,32 @@ class Symphony extends AbstractBase */ protected $policies; + /** + * Cache manager + * + * @var CacheManager + */ + protected $cacheManager; + + /** + * Record loader + * + * @var Loader + */ + protected $recordLoader; + + /** + * Constructor + * + * @param Loader $loader Record loader + * @param CacheManager $cacheManager Cache manager (optional) + */ + public function __construct(Loader $loader, CacheManager $cacheManager = null) + { + $this->recordLoader = $loader; + $this->cacheManager = $cacheManager; + } + /** * Initialize the driver. * @@ -120,13 +147,11 @@ class Symphony extends AbstractBase ]; // Initialize cache manager. - if (isset($configArray['PolicyCache']['type'])) { - $serviceManager = $this->getServiceLocator()->getServiceLocator(); - if ($serviceManager->has('VuFind\CacheManager')) { - $manager = $serviceManager->get('VuFind\CacheManager'); - $this->policyCache - = $manager->getCache($configArray['PolicyCache']['type']); - } + if (isset($configArray['PolicyCache']['type']) + && $this->cacheManager + ) { + $this->policyCache = $this->cacheManager + ->getCache($configArray['PolicyCache']['type']); } } @@ -375,8 +400,7 @@ class Symphony extends AbstractBase $entryNumber = $this->config['999Holdings']['entry_number']; - $records = $this->getServiceLocator()->getServiceLocator() - ->get('VuFind\RecordLoader')->loadBatch($ids); + $records = $this->recordLoader->loadBatch($ids); foreach ($records as $record) { $results = $record->getFormattedMarcDetails($entryNumber, $marcMap); foreach ($results as $result) { diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php index 88afb6c84c92bd5d2d8f898a07fcc33a716217a0..d5682b730702c7e92bb343bfeab15b684cbcb79b 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php @@ -46,7 +46,10 @@ class SymphonyTest extends \VuFindTest\Unit\TestCase */ public function __construct() { - $this->driver = new Symphony(); + $loader = $this->getMockBuilder('VuFind\Record\Loader') + ->disableOriginalConstructor()->getMock(); + + $this->driver = new Symphony($loader); } /** @@ -56,10 +59,6 @@ class SymphonyTest extends \VuFindTest\Unit\TestCase */ public function testBadBaseUrl() { - if (!version_compare(\PHP_VERSION, '5.3.4', '>=')) { - $this->markTestSkipped('Test requires PHP >= 5.3.4 (see VUFIND-660)'); - } - // Without SOAP functionality, we can't proceed: if (!class_exists('SoapClient')) { $this->markTestSkipped('SoapClient not installed');