Skip to content

Instantly share code, notes, and snippets.

@bemosior
Last active August 29, 2015 14:01
Show Gist options
  • Save bemosior/0786ced768ad114da2c0 to your computer and use it in GitHub Desktop.
Save bemosior/0786ced768ad114da2c0 to your computer and use it in GitHub Desktop.
VuFind ILS Driver Extension
<?php
namespace KlnLocal\Module\Configuration;
$config = array(
'controllers' => array(
'invokables' => array(
'instanceswitch' => 'KlnLocal\Controller\InstanceSwitchController'
)
),
'vufind' => array(
'config_reader' => array(
'abstract_factories' => array('VuFind\Config\PluginFactory'),
),
'plugin_managers' => array(
'ils_driver' => array(
'factories' => array(
'multibackend' => 'KlnLocal\ILS\Driver\MultiBackend',
),
),
),
)
);
return $config;
<?php
/**
* Multiple Backend Driver.
*
* PHP version 5
*
* Copyright (C) The National Library of Finland 2012.
*
* 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 VuFind
* @package ILSdrivers
* @author Ere Maijala <[email protected]>
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/building_an_ils_driver Wiki
*/
namespace KlnLocal\ILS\Driver;
use VuFind\ILS\Driver\MultiBackend as GenericMultiBackend,
VuFind\ILS\Driver\AbstractBase as AbstractBase,
VuFind\Exception\ILS as ILSException,
Zend\ServiceManager\ServiceLocatorAwareInterface,
Zend\ServiceManager\ServiceLocatorInterface,
Zend\Log\LoggerInterface;
/**
* Multiple Backend Driver.
*
* This driver allows to use multiple backends determined by a record id or
* user id prefix (e.g. source.12345).
*
* @category VuFind
* @package ILSdrivers
* @author Ere Maijala <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/building_an_ils_driver Wiki
*/
class MultiBackend extends GenericMultiBackend
implements ServiceLocatorAwareInterface, \Zend\Log\LoggerAwareInterface
{
/**
* Find Reserves
*
* Obtain information on course reserves.
*
* This version of findReserves was contributed by Matthew Hooper and includes
* support for electronic reserves (though eReserve support is still a work in
* progress).
*
* @param string $course ID from getCourses (empty string to match all)
* @param string $inst ID from getInstructors (empty string to match all)
* @param string $dept ID from getDepartments (empty string to match all)
*
* @throws ILSException
* @return array An array of associative arrays representing reserve items.
*/
public function findReserves($course, $inst, $dept)
{
$called = false;
$instance = $_SERVER['SERVER_NAME'];
$driverInst = substr($instance, strpos($instance,'-') + 1, strpos($instance,'.') - 6);
$recordsList = $this->runIfPossible($driverInst, 'findReserves', [$course,$inst,$debt], $called);
foreach ($recordsList as &$record) {
$record['BIB_ID'] = $driverInst . '.' . $record['BIB_ID'];
}
print_r($recordsList[0]['BIB_ID']);
return $recordsList;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment