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

Inject configuration into WorldCatUtils.

parent 50d8e038
Branches
Tags
No related merge requests found
...@@ -270,11 +270,16 @@ $config = array( ...@@ -270,11 +270,16 @@ $config = array(
$sm->get('VuFind\Http')->createClient() $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( 'invokables' => array(
'VuFind\RecordLoader' => 'VuFind\Record\Loader', 'VuFind\RecordLoader' => 'VuFind\Record\Loader',
'VuFind\SessionManager' => 'Zend\Session\SessionManager', 'VuFind\SessionManager' => 'Zend\Session\SessionManager',
'VuFind\WorldCatUtils' => 'VuFind\Connection\WorldCatUtils',
), ),
'initializers' => array( 'initializers' => array(
array('VuFind\ServiceManager\Initializer', 'initInstance'), array('VuFind\ServiceManager\Initializer', 'initInstance'),
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki * @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/ */
namespace VuFind\Connection; namespace VuFind\Connection;
use File_MARCXML, VuFind\Config\Reader as ConfigReader, use File_MARCXML, VuFind\XSLT\Processor as XSLTProcessor, Zend\Log\LoggerInterface;
VuFind\XSLT\Processor as XSLTProcessor, Zend\Log\LoggerInterface;
/** /**
* World Cat Utilities * World Cat Utilities
...@@ -49,6 +48,23 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface ...@@ -49,6 +48,23 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface
*/ */
protected $logger = false; 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 * Set the logger
* *
...@@ -82,13 +98,7 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface ...@@ -82,13 +98,7 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface
*/ */
protected function getWorldCatId() protected function getWorldCatId()
{ {
static $wcId = null; return $this->worldCatId;
if (is_null($wcId)) {
$config = ConfigReader::getConfig();
$wcId = isset($config->WorldCat->id)
? $config->WorldCat->id : false;
}
return $wcId;
} }
/** /**
......
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