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 4315 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 4343 of file grima-lib.php.

4344 {
4345 global $grima;
4346 $xml = $grima->getAllLibraries();
4347 $xpath = new DomXpath($xml);
4348 $codes = $xpath->query('//library/code');
4349 $libarray = array();
4350 foreach ($codes as $code) {
4351 $lib = new Library();
4352 $lib->loadFromAlma($code->nodeValue);
4353 $libarray[] = $lib;
4354 }
4355 return $libarray;
4356 }
class Library
Definition: grima-lib.php:4316
$grima
Definition: grima-lib.php:5143

References $grima, and AlmaObject\$xml.

◆ getAllLocations()

Library::getAllLocations ( )

get all locations configured for the library

Returns
array of Location objects

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

4391 {
4392 global $grima;
4393 $xml = $grima->getAllLocations($this['code']);
4394 $xpath = new DomXpath($xml);
4395 $codes = $xpath->query('//location/code');
4396 $locarray = array();
4397 foreach ($codes as $code) {
4398 $loc = new Location();
4399 $loc->loadFromAlma($this['code'], $code->nodeValue);
4400 $locarray[] = $loc;
4401 }
4402 return $locarray;
4403 }
class Location
Definition: grima-lib.php:4475

References $grima, and AlmaObject\$xml.

◆ 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 4366 of file grima-lib.php.

4367 {
4368 global $grima;
4369 $xml = $grima->getAllLibraries();
4370 $xpath = new DomXpath($xml);
4371 $codes = $xpath->query('//library/code');
4372
4373 foreach ($codes as $code) {
4374 if (! in_array($code, $otherthan)) {
4375 $lib = new Library();
4376 $lib->loadFromAlma($code);
4377 return $lib;
4378 }
4379 }
4380 throw new Exception("No libraries found.");
4381 }

References $grima, and AlmaObject\$xml.

Referenced by GrimaDataStore\setup().

◆ 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 4438 of file grima-lib.php.

4439 {
4440 global $grima;
4441
4442 $xml = $grima->getAllLibraries();
4443 $xpath = new DomXpath($xml);
4444 $library_codes = $xpath->query('//library/code');
4445
4446 foreach ($library_codes as $library_code) {
4447 $lib = new Library();
4448 $lib->loadFromAlma($library_code->nodeValue);
4449 $arr = array();
4450 foreach ($otherthan as $other) {
4451 if ($other[0] == $library_code->nodeValue) {
4452 $arr[] = $other[1];
4453 }
4454 }
4455 try {
4456 $loc = $lib->getOneLocation($arr);
4457 return $loc;
4458 } catch (Exception $e) {
4459 continue;
4460 }
4461 }
4462 throw new Exception("No suitable library/location found.");
4463 }

References $grima, and AlmaObject\$xml.

◆ 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 4413 of file grima-lib.php.

4414 {
4415 global $grima;
4416 $xml = $grima->getAllLocations($this['code']);
4417 $xpath = new DomXpath($xml);
4418 $codes = $xpath->query('//location/code');
4419 foreach ($codes as $code) {
4420 if (! in_array($code->nodeValue, $otherthan)) {
4421 $loc = new Location();
4422 $loc->loadFromAlma($this['code'], $code->nodeValue);
4423 return $loc;
4424 }
4425 }
4426 throw new Exception("No locations found.");
4427 }

References $grima, and AlmaObject\$xml.

◆ loadFromAlma()

Library::loadFromAlma (   $code )

populate library with info from Alma

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

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

4331 {
4332 global $grima;
4333 $this->xml = $grima->getLibrary($code);
4334 }

References $grima.

Member Data Documentation

◆ $el_address

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

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


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