diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 8c4bb408ed9cf0101613a330c61d42c4991ef528..81a40b7e60de7cba59f40c46e72c90b00b7ed183 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -270,11 +270,16 @@ $config = array( $sm->get('VuFind\Http')->createClient() ); }, + 'VuFind\WorldCatUtils' => function ($sm) { + $config = $sm->get('VuFind\Config')->get('config'); + $wcId = isset($config->WorldCat->id) + ? $config->WorldCat->id : false; + return new \VuFind\Connection\WorldCatUtils($wcId); + }, ), 'invokables' => array( 'VuFind\RecordLoader' => 'VuFind\Record\Loader', 'VuFind\SessionManager' => 'Zend\Session\SessionManager', - 'VuFind\WorldCatUtils' => 'VuFind\Connection\WorldCatUtils', ), 'initializers' => array( array('VuFind\ServiceManager\Initializer', 'initInstance'), diff --git a/module/VuFind/src/VuFind/Connection/WorldCatUtils.php b/module/VuFind/src/VuFind/Connection/WorldCatUtils.php index a5668984969cd84fd0b541fcc89dd5afb9bbfb10..a5b600deee79a6859bbaea58f5fc59c7d03de942 100644 --- a/module/VuFind/src/VuFind/Connection/WorldCatUtils.php +++ b/module/VuFind/src/VuFind/Connection/WorldCatUtils.php @@ -26,8 +26,7 @@ * @link http://vufind.org/wiki/vufind2:developer_manual Wiki */ namespace VuFind\Connection; -use File_MARCXML, VuFind\Config\Reader as ConfigReader, - VuFind\XSLT\Processor as XSLTProcessor, Zend\Log\LoggerInterface; +use File_MARCXML, VuFind\XSLT\Processor as XSLTProcessor, Zend\Log\LoggerInterface; /** * World Cat Utilities @@ -49,6 +48,23 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface */ protected $logger = false; + /** + * WorldCat ID + * + * @var string + */ + protected $worldCatId; + + /** + * Constructor + * + * @param string $worldcatId WorldCat ID + */ + public function __construct($worldCatId) + { + $this->worldCatId = $worldCatId; + } + /** * Set the logger * @@ -82,13 +98,7 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface */ protected function getWorldCatId() { - static $wcId = null; - if (is_null($wcId)) { - $config = ConfigReader::getConfig(); - $wcId = isset($config->WorldCat->id) - ? $config->WorldCat->id : false; - } - return $wcId; + return $this->worldCatId; } /**