@@ 11-55 (lines=45) @@ | ||
8 | /** |
|
9 | * A single Library resource. |
|
10 | */ |
|
11 | class Library extends LazyResource |
|
12 | { |
|
13 | /** @var string */ |
|
14 | public $code; |
|
15 | ||
16 | /** @var Locations */ |
|
17 | public $locations; |
|
18 | ||
19 | /** |
|
20 | * Library constructor. |
|
21 | * |
|
22 | * @param Client $client |
|
23 | * @param string $code |
|
24 | */ |
|
25 | public function __construct(Client $client, $code) |
|
26 | { |
|
27 | parent::__construct($client); |
|
28 | $this->code = $code; |
|
29 | $this->locations = Locations::make($this->client, $this); |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * Check if we have the full representation of our data object. |
|
34 | * For libraries, it seems like we get the same data in the list |
|
35 | * response as in the single-item response, so we just check some |
|
36 | * random element. |
|
37 | * |
|
38 | * @param \stdClass $data |
|
39 | * |
|
40 | * @return bool |
|
41 | */ |
|
42 | protected function isInitialized($data) |
|
43 | { |
|
44 | return isset($data->path); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * Generate the base URL for this resource. |
|
49 | * |
|
50 | * @return string |
|
51 | */ |
|
52 | protected function urlBase() |
|
53 | { |
|
54 | return "/conf/libraries/{$this->code}"; |
|
55 | } |
|
56 | } |
|
57 |
@@ 11-46 (lines=36) @@ | ||
8 | /** |
|
9 | * A single Location resource. |
|
10 | */ |
|
11 | class Location extends LazyResource |
|
12 | { |
|
13 | /** @var Library */ |
|
14 | public $library; |
|
15 | ||
16 | /** @var string */ |
|
17 | public $code; |
|
18 | ||
19 | public function __construct(Client $client, Library $library, $code) |
|
20 | { |
|
21 | parent::__construct($client); |
|
22 | $this->library = $library; |
|
23 | $this->code = $code; |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * Check if we have the full representation of our data object. |
|
28 | * |
|
29 | * @param \stdClass $data |
|
30 | * |
|
31 | * @return bool |
|
32 | */ |
|
33 | protected function isInitialized($data) |
|
34 | { |
|
35 | return isset($data->location); |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * Generate the base URL for this resource. |
|
40 | * |
|
41 | * @return string |
|
42 | */ |
|
43 | protected function urlBase() |
|
44 | { |
|
45 | return "/conf/libraries/{$this->library->code}/locations/{$this->code}"; |
|
46 | } |
|
47 | } |
|
48 |