File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Scriptotek \Marc \Fields ;
4
+
5
+ class ControlField extends Field implements FieldInterface
6
+ {
7
+ public function __toString ()
8
+ {
9
+ return $ this ->field ->getData ();
10
+ }
11
+ }
Original file line number Diff line number Diff line change @@ -127,6 +127,13 @@ public function getTitle()
127
127
return $ field ? $ this ->makeField ('Title ' , $ field ) : null ;
128
128
}
129
129
130
+ public function getId ()
131
+ {
132
+ $ field = $ this ->record ->getField ('001 ' );
133
+
134
+ return $ field ? $ this ->makeField ('ControlField ' , $ field ) : null ;
135
+ }
136
+
130
137
/*************************************************************************
131
138
* Support methods
132
139
*************************************************************************/
Original file line number Diff line number Diff line change @@ -36,4 +36,16 @@ public function test020withoutA()
36
36
$ record = Record::fromString ($ source );
37
37
$ this ->assertEquals (array ('' ), $ record ->isbns );
38
38
}
39
+
40
+ public function testId ()
41
+ {
42
+ $ source = '<?xml version="1.0" encoding="UTF-8" ?>
43
+ <record xmlns="http://www.loc.gov/MARC21/slim">
44
+ <leader>99999cam a2299999 u 4500</leader>
45
+ <controlfield tag="001">98218834x</controlfield>
46
+ </record> ' ;
47
+
48
+ $ record = Record::fromString ($ source );
49
+ $ this ->assertEquals ('98218834x ' , $ record ->id );
50
+ }
39
51
}
You can’t perform that action at this time.
0 commit comments