Skip to content

Commit

Permalink
[FINNA-1206] MARC: Move ISSN field specs to a member variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Dec 12, 2023
1 parent 8206b5c commit f3da9db
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Anything marked with [**BC**] is known to affect backward compatibility with pre

### Changed

- Format of $isbnFields definition array in Marc.php has been changed to include the type of ISBN field. It can be used to avoid reporting invalid ISBNs or extra content in combined fields in the `warnings_field` index field.
- Format of $isbnFields and $issnFields definition arrays in Marc.php have been changed to include the type of the field. It can be used to avoid reporting invalid e.g. ISBNs or extra content in combined fields in the `warnings_field` index field.

## 2.2.0 - 2023-11-13

Expand Down
46 changes: 34 additions & 12 deletions src/RecordManager/Base/Record/Marc.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@ class Marc extends AbstractRecord
],
];

/**
* Field specs for ISSN fields
*
* 'type' can be 'normal', 'combined' or 'invalid'; it's not currently used but
* exists for future needs and compatibility with $isbnFields.
*
* @var array
*/
protected $issnFields = [
[
'type' => 'normal',
'selector' => [
[MarcHandler::GET_NORMAL, '022', ['a']],
[MarcHandler::GET_NORMAL, '440', ['x']],
[MarcHandler::GET_NORMAL, '490', ['x']],
[MarcHandler::GET_NORMAL, '730', ['x']],
[MarcHandler::GET_NORMAL, '773', ['x']],
[MarcHandler::GET_NORMAL, '776', ['x']],
[MarcHandler::GET_NORMAL, '780', ['x']],
[MarcHandler::GET_NORMAL, '785', ['x']],
],
],
];

/**
* MARC record creation callback
*
Expand Down Expand Up @@ -451,18 +475,16 @@ public function toSolrArray(Database $db = null)
}
}
}
$data['issn'] = $this->getFieldsSubfields(
[
[MarcHandler::GET_NORMAL, '022', ['a']],
[MarcHandler::GET_NORMAL, '440', ['x']],
[MarcHandler::GET_NORMAL, '490', ['x']],
[MarcHandler::GET_NORMAL, '730', ['x']],
[MarcHandler::GET_NORMAL, '773', ['x']],
[MarcHandler::GET_NORMAL, '776', ['x']],
[MarcHandler::GET_NORMAL, '780', ['x']],
[MarcHandler::GET_NORMAL, '785', ['x']],
]
);

foreach ($this->issnFields as $fieldSpec) {
// phpcs:ignore
/** @psalm-suppress DuplicateArrayKey,InvalidOperand */
$data['issn'] = [
...($data['issn'] ?? []),
...$this->getFieldsSubfields($fieldSpec['selector']),
];
}

$data['doi_str_mv'] = $this->getDOIs();

$cn = $this->getFirstFieldSubfields(
Expand Down

0 comments on commit f3da9db

Please sign in to comment.