MarcReaderTrait
Functions for reading MARC records.
Assumption: raw MARC data can be found in $this->fields['fullrecord'].
Assumption: VuFind config available as $this->mainConfig
Tags
Table of Contents
- $lazyMarcReader : mixed
- MARC reader. Access only via getMarcReader() as this is initialized lazily.
- $marcReaderClass : string
- MARC reader class to use.
- getMarcReader() : MarcReader
- Get access to the MarcReader object.
- getRawMarcData() : string
- Retrieve the raw MARC data for this record; note that format may vary depending on what was indexed (e.g. XML vs. binary MARC).
- getFieldArray() : array<string|int, mixed>
- Return an array of all values extracted from the specified field/subfield combination. If multiple subfields are specified and $concat is true, they will be concatenated together in the order listed -- each entry in the array will correspond with a single MARC field. If $concat is false, the return array will contain separate entries for separate subfields.
- getFirstFieldValue() : string
- Get the first value matching the specified MARC field and subfields.
- getPublicationInfo() : array<string|int, mixed>
- Get the item's publication information
- getSubfield() : string
- Return first subfield with the given code in the provided MARC field
- getSubfieldArray() : array<string|int, mixed>
- Return an array of non-empty subfield values found in the provided MARC field. If $concat is true, the array will contain either zero or one entries (empty array if no subfields found, subfield values concatenated together in specified order if found). If concat is false, the array will contain a separate entry for each subfield value found.
- getSubfields() : array<string|int, mixed>
- Return all subfields with the given code in the provided MARC field
Properties
$lazyMarcReader
MARC reader. Access only via getMarcReader() as this is initialized lazily.
protected
mixed
$lazyMarcReader
= null
$marcReaderClass
MARC reader class to use.
protected
string
$marcReaderClass
= \VuFind\Marc\MarcReader::class
Methods
getMarcReader()
Get access to the MarcReader object.
public
getMarcReader() : MarcReader
Return values
MarcReader —getRawMarcData()
Retrieve the raw MARC data for this record; note that format may vary depending on what was indexed (e.g. XML vs. binary MARC).
public
getRawMarcData() : string
Return values
string —getFieldArray()
Return an array of all values extracted from the specified field/subfield combination. If multiple subfields are specified and $concat is true, they will be concatenated together in the order listed -- each entry in the array will correspond with a single MARC field. If $concat is false, the return array will contain separate entries for separate subfields.
protected
getFieldArray(string $field[, array<string|int, mixed> $subfields = null ][, bool $concat = true ][, string $separator = ' ' ]) : array<string|int, mixed>
Parameters
- $field : string
-
The MARC field number to read
- $subfields : array<string|int, mixed> = null
-
The MARC subfield codes to read
- $concat : bool = true
-
Should we concatenate subfields?
- $separator : string = ' '
-
Separator string (used only when $concat === true)
Return values
array<string|int, mixed> —getFirstFieldValue()
Get the first value matching the specified MARC field and subfields.
protected
getFirstFieldValue(string $field[, array<string|int, mixed> $subfields = null ]) : string
If multiple subfields are specified, they will be concatenated together.
Parameters
- $field : string
-
The MARC field to read
- $subfields : array<string|int, mixed> = null
-
The MARC subfield codes to read
Return values
string —getPublicationInfo()
Get the item's publication information
protected
getPublicationInfo([string $subfield = 'a' ]) : array<string|int, mixed>
Parameters
- $subfield : string = 'a'
-
The subfield to retrieve ('a' = location, 'c' = date)
Return values
array<string|int, mixed> —getSubfield()
Return first subfield with the given code in the provided MARC field
protected
getSubfield(array<string|int, mixed> $field, string $subfield) : string
Parameters
- $field : array<string|int, mixed>
-
Result from MarcReader::getFields
- $subfield : string
-
The MARC subfield code to get
Return values
string —getSubfieldArray()
Return an array of non-empty subfield values found in the provided MARC field. If $concat is true, the array will contain either zero or one entries (empty array if no subfields found, subfield values concatenated together in specified order if found). If concat is false, the array will contain a separate entry for each subfield value found.
protected
getSubfieldArray(array<string|int, mixed> $currentField, array<string|int, mixed> $subfields[, bool $concat = true ][, string $separator = ' ' ]) : array<string|int, mixed>
Parameters
- $currentField : array<string|int, mixed>
-
Result from MarcReader::getFields
- $subfields : array<string|int, mixed>
-
The MARC subfield codes to read
- $concat : bool = true
-
Should we concatenate subfields?
- $separator : string = ' '
-
Separator string (used only when $concat === true)
Return values
array<string|int, mixed> —getSubfields()
Return all subfields with the given code in the provided MARC field
protected
getSubfields(array<string|int, mixed> $field, string $subfield) : array<string|int, mixed>
Parameters
- $field : array<string|int, mixed>
-
Result from MarcReader::getFields
- $subfield : string
-
The MARC subfield code to get