| @@ 13-69 (lines=57) @@ | ||
| 10 | /** |
|
| 11 | * Iterable collection of Holding resources belonging to some Bib resource. |
|
| 12 | */ |
|
| 13 | class Holdings extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess |
|
| 14 | { |
|
| 15 | use ReadOnlyArrayAccess; |
|
| 16 | use IterableCollection; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * The Bib this Holdings list belongs to. |
|
| 20 | * |
|
| 21 | * @var Bib |
|
| 22 | */ |
|
| 23 | public $bib; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Holdings constructor. |
|
| 27 | * |
|
| 28 | * @param Client $client |
|
| 29 | * @param Bib $bib |
|
| 30 | */ |
|
| 31 | public function __construct(Client $client, Bib $bib) |
|
| 32 | { |
|
| 33 | parent::__construct($client, 'holding'); |
|
| 34 | $this->bib = $bib; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Get a single holding record by id. |
|
| 39 | * |
|
| 40 | * @param string $holding_id |
|
| 41 | * @return Holding |
|
| 42 | */ |
|
| 43 | public function get($holding_id) |
|
| 44 | { |
|
| 45 | return Holding::make($this->client, $this->bib, $holding_id); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Convert a data element to a resource object. |
|
| 50 | * |
|
| 51 | * @param $data |
|
| 52 | * @return Holding |
|
| 53 | */ |
|
| 54 | protected function convertToResource($data) |
|
| 55 | { |
|
| 56 | return Holding::make($this->client, $this->bib, $data->holding_id) |
|
| 57 | ->init($data); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * Generate the base URL for this resource. |
|
| 62 | * |
|
| 63 | * @return string |
|
| 64 | */ |
|
| 65 | protected function urlBase() |
|
| 66 | { |
|
| 67 | return "/bibs/{$this->bib->mms_id}/holdings"; |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| @@ 13-69 (lines=57) @@ | ||
| 10 | /** |
|
| 11 | * Iterable collection of Location resources. |
|
| 12 | */ |
|
| 13 | class Locations extends LazyResourceList implements \ArrayAccess, \Countable, \Iterator |
|
| 14 | { |
|
| 15 | use ReadOnlyArrayAccess; |
|
| 16 | use IterableCollection; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * The Library this Locations list belongs to. |
|
| 20 | * |
|
| 21 | * @var Library |
|
| 22 | */ |
|
| 23 | protected $library; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Locations constructor. |
|
| 27 | * |
|
| 28 | * @param Client $client |
|
| 29 | * @param Library $library |
|
| 30 | */ |
|
| 31 | public function __construct(Client $client, Library $library) |
|
| 32 | { |
|
| 33 | parent::__construct($client, 'location'); |
|
| 34 | $this->library = $library; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Get a single location by its location code. |
|
| 39 | * |
|
| 40 | * @param string $code |
|
| 41 | * @return Location |
|
| 42 | */ |
|
| 43 | public function get($code) |
|
| 44 | { |
|
| 45 | return Location::make($this->client, $this->library, $code); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Convert a data element to a resource object. |
|
| 50 | * |
|
| 51 | * @param $data |
|
| 52 | * @return Location |
|
| 53 | */ |
|
| 54 | protected function convertToResource($data) |
|
| 55 | { |
|
| 56 | return Location::make($this->client, $this->library, $data->code) |
|
| 57 | ->init($data); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * Generate the base URL for this resource. |
|
| 62 | * |
|
| 63 | * @return string |
|
| 64 | */ |
|
| 65 | protected function urlBase() |
|
| 66 | { |
|
| 67 | return "/conf/libraries/{$this->library->code}/locations"; |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| @@ 13-68 (lines=56) @@ | ||
| 10 | /** |
|
| 11 | * Iterable collection of Fee resources. |
|
| 12 | */ |
|
| 13 | class Fees extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess |
|
| 14 | { |
|
| 15 | use ReadOnlyArrayAccess; |
|
| 16 | use IterableCollection; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * The User object this Fees list belongs to. |
|
| 20 | * |
|
| 21 | * @var User |
|
| 22 | */ |
|
| 23 | public $user; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Fees constructor. |
|
| 27 | * |
|
| 28 | * @param Client $client |
|
| 29 | * @param User $user |
|
| 30 | */ |
|
| 31 | public function __construct(Client $client, User $user) |
|
| 32 | { |
|
| 33 | parent::__construct($client, 'fee'); |
|
| 34 | $this->user = $user; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Get a single Fee by id. |
|
| 39 | * |
|
| 40 | * @param string $id |
|
| 41 | * @return Fee |
|
| 42 | */ |
|
| 43 | public function get($id) |
|
| 44 | { |
|
| 45 | return Fee::make($this->client, $this->user, $id); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Convert a retrieved resource object to a model object. |
|
| 50 | * |
|
| 51 | * @param $data |
|
| 52 | * @return Fee |
|
| 53 | */ |
|
| 54 | public function convertToResource($data) |
|
| 55 | { |
|
| 56 | return $this->get($data->id)->init($data); |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Generate the base URL for this resource. |
|
| 61 | * |
|
| 62 | * @return string |
|
| 63 | */ |
|
| 64 | protected function urlBase() |
|
| 65 | { |
|
| 66 | return "/users/{$this->user->id}/fees"; |
|
| 67 | } |
|
| 68 | } |
|
| 69 | ||
| @@ 13-53 (lines=41) @@ | ||
| 10 | /** |
|
| 11 | * Iterable collection of Request resources. |
|
| 12 | */ |
|
| 13 | class Requests extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess |
|
| 14 | { |
|
| 15 | use ReadOnlyArrayAccess; |
|
| 16 | use IterableCollection; |
|
| 17 | ||
| 18 | protected $_urlBase; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * Requests constructor. |
|
| 22 | * |
|
| 23 | * @param Client $client |
|
| 24 | * @param string $url |
|
| 25 | */ |
|
| 26 | public function __construct(Client $client, $url) |
|
| 27 | { |
|
| 28 | parent::__construct($client, 'user_request'); |
|
| 29 | $this->_urlBase = $url; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * Convert a data element to a resource object. |
|
| 34 | * |
|
| 35 | * @param $data |
|
| 36 | * @return Request |
|
| 37 | */ |
|
| 38 | protected function convertToResource($data) |
|
| 39 | { |
|
| 40 | return Request::make($this->client, User::make($this->client, $data->user_primary_id), $data->request_id) |
|
| 41 | ->init($data); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Generate the base URL for this resource. |
|
| 46 | * |
|
| 47 | * @return string |
|
| 48 | */ |
|
| 49 | protected function urlBase() |
|
| 50 | { |
|
| 51 | return $this->_urlBase; |
|
| 52 | } |
|
| 53 | } |
|
| 54 | ||