Grima  2018-08
Whispering into Alma's ear
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Library Class Reference

class Library More...

Inheritance diagram for Library:
AlmaObject

Public Member Functions

  loadFromAlma ($code)
  populate library with info from Alma More...
 
  getAllLocations ()
  get all locations configured for the library More...
 
  getOneLocation ($otherthan=array())
  get one location configured for the library More...
 
- Public Member Functions inherited from AlmaObject
  __construct ()
  create new blank Alma Object More...
 
  offsetExists ($offset)
 
  offsetGet ($offset)
 
  offsetSet ($offset, $value)
 
  offsetUnset ($offset)
 

Static Public Member Functions

static  getAllLibraries ()
  get all libraries configured for the institution More...
 
static  getOneLibrary ($otherthan=array())
  get one library configured by the institution More...
 
static  getOneLibraryLocation ($otherthan=array())
  get one library configured by the institution More...
 

Public Attributes

  $el_address
 
- Public Attributes inherited from AlmaObject
  $el_access = array()
 
  $xml
 
  $templateDir = __DIR__ . "/templates"
 

Detailed Description

class Library

Definition at line 3572 of file grima-lib.php.

Member Function Documentation

◆ getAllLibraries()

static Library::getAllLibraries ( )
static

get all libraries configured for the institution

Returns
array of Library objects

Definition at line 3598 of file grima-lib.php.

References $grima.

3598  {
3599  global $grima;
3600  $xml = $grima->getAllLibraries();
3601  $xpath = new DomXpath($xml);
3602  $codes = $xpath->query('//library/code');
3603  $libarray = array();
3604  foreach ($codes as $code) {
3605  $lib = new Library();
3606  $lib->loadFromAlma($code->nodeValue);
3607  $libarray[] = $lib;
3608  }
3609  return $libarray;
3610  }
class Library
Definition: grima-lib.php:3572
$grima
Definition: grima-lib.php:4293

◆ getAllLocations()

Library::getAllLocations ( )

get all locations configured for the library

Returns
array of Location objects

Definition at line 3643 of file grima-lib.php.

References $grima.

3643  {
3644  global $grima;
3645  $xml = $grima->getAllLocations($this['code']);
3646  $xpath = new DomXpath($xml);
3647  $codes = $xpath->query('//location/code');
3648  $locarray = array();
3649  foreach ($codes as $code) {
3650  $loc = new Location();
3651  $loc->loadFromAlma($this['code'], $code->nodeValue);
3652  $locarray[] = $loc;
3653  }
3654  return $locarray;
3655  }
$grima
Definition: grima-lib.php:4293
class Location
Definition: grima-lib.php:3722

◆ getOneLibrary()

static Library::getOneLibrary (   $otherthan = array() )
static

get one library configured by the institution

Parameters
Array $otherthan - a list of codes for libraries not wanted
Returns
one library object

Definition at line 3620 of file grima-lib.php.

References $grima.

Referenced by GrimaDataStore\setup().

3620  {
3621  global $grima;
3622  $xml = $grima->getAllLibraries();
3623  $xpath = new DomXpath($xml);
3624  $codes = $xpath->query('//library/code');
3625 
3626  foreach ($codes as $code) {
3627  if (! in_array($code,$otherthan)) {
3628  $lib = new Library();
3629  $lib->loadFromAlma($code);
3630  return $lib;
3631  }
3632  }
3633  throw new Exception("No libraries found.");
3634  }
class Library
Definition: grima-lib.php:3572
$grima
Definition: grima-lib.php:4293

◆ getOneLibraryLocation()

static Library::getOneLibraryLocation (   $otherthan = array() )
static

get one library configured by the institution

Parameters
Array $otherthan - a list of pairs of codes for libraries/locations not wanted
Returns
one library object

Definition at line 3689 of file grima-lib.php.

References $grima.

3689  {
3690  global $grima;
3691 
3692  $xml = $grima->getAllLibraries();
3693  $xpath = new DomXpath($xml);
3694  $library_codes = $xpath->query('//library/code');
3695 
3696  foreach ($library_codes as $library_code) {
3697  $lib = new Library();
3698  $lib->loadFromAlma($library_code->nodeValue);
3699  $arr = array();
3700  foreach ($otherthan as $other) {
3701  if ($other[0] == $library_code->nodeValue) {
3702  $arr[] = $other[1];
3703  }
3704  }
3705  try {
3706  $loc = $lib->getOneLocation($arr);
3707  return $loc;
3708  } catch (Exception $e) {
3709  continue;
3710  }
3711  }
3712  throw new Exception("No suitable library/location found.");
3713  }
class Library
Definition: grima-lib.php:3572
$grima
Definition: grima-lib.php:4293

◆ getOneLocation()

Library::getOneLocation (   $otherthan = array() )

get one location configured for the library

Parameters
Array $otherthan - a list of codes for locations not wanted
Returns
Location object

Definition at line 3665 of file grima-lib.php.

References $grima.

3665  {
3666  global $grima;
3667  $xml = $grima->getAllLocations($this['code']);
3668  $xpath = new DomXpath($xml);
3669  $codes = $xpath->query('//location/code');
3670  foreach ($codes as $code) {
3671  if (! in_array($code->nodeValue,$otherthan)) {
3672  $loc = new Location();
3673  $loc->loadFromAlma($this['code'],$code->nodeValue);
3674  return $loc;
3675  }
3676  }
3677  throw new Exception("No locations found.");
3678  }
$grima
Definition: grima-lib.php:4293
class Location
Definition: grima-lib.php:3722

◆ loadFromAlma()

Library::loadFromAlma (   $code )

populate library with info from Alma

Parameters
String $code - code of library to pull from Alma

Definition at line 3586 of file grima-lib.php.

References $grima.

3586  {
3587  global $grima;
3588  $this->xml = $grima->getLibrary($code);
3589  }
$grima
Definition: grima-lib.php:4293

Member Data Documentation

◆ $el_address

Library::$el_address
Initial value:
= array(
'code' => '//code',
'path' => '//path',
'name' => '//name',
'resource_sharing' => '//resource_sharing',
)

Definition at line 3573 of file grima-lib.php.


The documentation for this class was generated from the following file: