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

Eliminated dependency between \VuFind\RecordDriver\WorldCat and \VuFind\Connection\WorldCat.

parent f671b35c
No related merge requests found
...@@ -303,16 +303,4 @@ class WorldCat extends SolrMarc ...@@ -303,16 +303,4 @@ class WorldCat extends SolrMarc
{ {
return $this->getFieldArray('780', array('a', 's', 't')); return $this->getFieldArray('780', array('a', 's', 't'));
} }
/**
* Get holdings information from WorldCat.
*
* @return SimpleXMLElement
*/
public function getWorldCatHoldings()
{
$wc = $this->getServiceLocator()->getServiceLocator()
->get('VuFind\WorldCatConnection');
return $wc->getHoldings($this->getUniqueId());
}
} }
<?php
/**
* WorldCat view helper
*
* PHP version 5
*
* Copyright (C) Villanova University 2010.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package View_Helpers
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
namespace VuFind\View\Helper\Root;
use Zend\View\Helper\AbstractHelper;
/**
* WorldCat view helper
*
* @category VuFind2
* @package View_Helpers
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
class WorldCat extends AbstractHelper
{
/**
* WorldCat connection
*
* @var \VuFind\Connection\WorldCat
*/
protected $wc;
/**
* Constructor
*
* @param \VuFind\Connection\WorldCat $wc WorldCat connection
*/
public function __construct(\VuFind\Connection\WorldCat $wc)
{
$this->wc = $wc;
}
/**
* Get holdings information from WorldCat.
*
* @param string $id Record ID
*
* @return SimpleXMLElement
*/
public function getHoldings($id)
{
return $this->wc->getHoldings($id);
}
}
\ No newline at end of file
<? $holdings = $this->driver->getWorldCatHoldings(); if ($holdings && count($holdings) > 0): ?> <? $holdings = $this->worldcat()->getHoldings($this->driver->getUniqueId()); if ($holdings && count($holdings) > 0): ?>
<h3><?=$this->transEsc('Holdings at Other Libraries')?></h3> <h3><?=$this->transEsc('Holdings at Other Libraries')?></h3>
<table cellpadding="2" cellspacing="0" border="0" class="citation" width="100%"> <table cellpadding="2" cellspacing="0" border="0" class="citation" width="100%">
<? foreach ($holdings as $holding): ?> <? foreach ($holdings as $holding): ?>
......
<? $holdings = $this->driver->getWorldCatHoldings(); if ($holdings && count($holdings) > 0): ?> <? $holdings = $this->worldcat()->getHoldings($this->driver->getUniqueId()); if ($holdings && count($holdings) > 0): ?>
<h3><?=$this->transEsc('Holdings at Other Libraries')?></h3> <h3><?=$this->transEsc('Holdings at Other Libraries')?></h3>
<table cellpadding="2" cellspacing="0" border="0" class="citation" width="100%"> <table cellpadding="2" cellspacing="0" border="0" class="citation" width="100%">
<? foreach ($holdings as $holding): ?> <? foreach ($holdings as $holding): ?>
......
...@@ -114,6 +114,11 @@ return array( ...@@ -114,6 +114,11 @@ return array(
$sm->getServiceLocator()->get('VuFind\Config')->get('config') $sm->getServiceLocator()->get('VuFind\Config')->get('config')
); );
}, },
'worldcat' => function ($sm) {
return new \VuFind\View\Helper\Root\WorldCat(
$sm->getServiceLocator()->get('VuFind\WorldCatConnection')
);
}
), ),
'invokables' => array( 'invokables' => array(
'addellipsis' => 'VuFind\View\Helper\Root\AddEllipsis', 'addellipsis' => 'VuFind\View\Helper\Root\AddEllipsis',
......
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