File tree Expand file tree Collapse file tree 4 files changed +95
-0
lines changed Expand file tree Collapse file tree 4 files changed +95
-0
lines changed Original file line number Diff line number Diff line change 24
24
use Scriptotek \Alma \Conf \Jobs ;
25
25
use Scriptotek \Alma \Conf \Libraries ;
26
26
use Scriptotek \Alma \Conf \Library ;
27
+ use Scriptotek \Alma \Conf \CodeTables ;
27
28
use Scriptotek \Alma \Exception \ClientException as AlmaClientException ;
28
29
use Scriptotek \Alma \Exception \InvalidApiKey ;
29
30
use Scriptotek \Alma \Exception \MaxNumberOfAttemptsExhausted ;
@@ -103,6 +104,11 @@ class Client
103
104
*/
104
105
public $ jobs ;
105
106
107
+ /**
108
+ * @var CodeTables
109
+ */
110
+ public $ codetables ;
111
+
106
112
/**
107
113
* @var TaskLists
108
114
*/
@@ -152,6 +158,7 @@ public function __construct(
152
158
$ this ->conf = new Conf ($ this );
153
159
$ this ->libraries = $ this ->conf ->libraries ; // shortcut
154
160
$ this ->jobs = $ this ->conf ->jobs ; // shortcut
161
+ $ this ->codetables = $ this ->conf ->codetables ; // shortcut
155
162
156
163
$ this ->taskLists = new TaskLists ($ this );
157
164
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Scriptotek \Alma \Conf ;
4
+
5
+ use Scriptotek \Alma \Client ;
6
+ use Scriptotek \Alma \Model \LazyResource ;
7
+
8
+ /**
9
+ * A single CodeTable resource.
10
+ */
11
+ class CodeTable extends LazyResource
12
+ {
13
+ /** @var string */
14
+ public $ code ;
15
+
16
+ /**
17
+ * CodeTable constructor.
18
+ *
19
+ * @param Client $client
20
+ * @param string $code
21
+ */
22
+ public function __construct (Client $ client , $ code )
23
+ {
24
+ parent ::__construct ($ client );
25
+ $ this ->code = $ code ;
26
+ }
27
+
28
+ /**
29
+ * Check if we have the full representation of our data object.
30
+ *
31
+ * @param \stdClass $data
32
+ *
33
+ * @return bool
34
+ */
35
+ protected function isInitialized ($ data )
36
+ {
37
+ return isset ($ data ->name );
38
+ }
39
+
40
+ /**
41
+ * Generate the base URL for this resource.
42
+ *
43
+ * @return string
44
+ */
45
+ protected function urlBase ()
46
+ {
47
+ return "/conf/code-tables/ {$ this ->code }" ;
48
+ }
49
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Scriptotek \Alma \Conf ;
4
+
5
+ use Scriptotek \Alma \Client ;
6
+ use Scriptotek \Alma \Model \ReadOnlyArrayAccess ;
7
+
8
+ /**
9
+ * A non-iterable collection of CodeTable resources
10
+ */
11
+ class CodeTables implements \ArrayAccess
12
+ {
13
+ use ReadOnlyArrayAccess;
14
+
15
+ protected $ client ;
16
+
17
+ /**
18
+ * CodeTables constructor.
19
+ *
20
+ * @param Client $client
21
+ */
22
+ public function __construct (Client $ client )
23
+ {
24
+ $ this ->client = $ client ;
25
+ }
26
+
27
+ /**
28
+ * Get a CodeTable by identifier
29
+ *
30
+ * @param $code The identifier of a CodeTable
31
+ *
32
+ * @return CodeTable
33
+ */
34
+ public function get ($ code )
35
+ {
36
+ return CodeTable::make ($ this ->client , $ code );
37
+ }
38
+ }
Original file line number Diff line number Diff line change @@ -12,5 +12,6 @@ public function __construct(Client $client)
12
12
$ this ->client = $ client ;
13
13
$ this ->libraries = new Libraries ($ client );
14
14
$ this ->jobs = new Jobs ($ client );
15
+ $ this ->codetables = new CodeTables ($ client );
15
16
}
16
17
}
You can’t perform that action at this time.
0 commit comments