Skip to content
Snippets Groups Projects
Commit db446d18 authored by Alexander Purr's avatar Alexander Purr Committed by Sebastian Kehr
Browse files

refs #16458 [fid] order hydrator adds more record parameters to DTO order

* helper function object-to-array
* use temporarily title as order label
* bugfix access pages key
parent 357463dd
No related merge requests found
......@@ -27,24 +27,43 @@ class OrderHydrator extends AbstractHydrator {
$object->setType($data['type']);
$object->setUser($data['user']);
$pages = array_key_exists('pages',$data) ? $data['pages'] : null;
/* Collect needed record data */
$recordId = $driver->tryMethod('getUniqueID');
$id = $driver->tryMethod('getUniqueID');
$title = $driver->tryMethod('getTitle');
$publicationDetails = (array) $driver->tryMethod('getPublicationDetails')[0];
$publicationDetails = $this->toArray( $driver->tryMethod('getPublicationDetails')[0] );
$authors = $driver->tryMethod('getDeduplicatedAuthors');
$primaryAuthor = $driver->tryMethod('getPrimaryAuthor');
$secondaryAuthors = $driver->tryMethod('getSecondaryAuthors');
$isbn = $driver->tryMethod('getCleanISBN');
$issn = $driver->tryMethod('getCleanISSN');
$languages = $driver->tryMethod('getLanguages');
$price = $driver->tryMethod('getPrice');
$record = compact(
'recordId',
'id',
'title',
'publicationDetails',
'authors',
'primaryAuthor',
'secondaryAuthors',
'issn',
'isbn'
'isbn',
'languages',
'price',
'pages'
);
$object->setData(compact('record'));
$object->setLabel($title);
return;
}
public function toArray ($object) : array {
$array = (array) $object;
$keys = str_replace( '*', '', array_keys( $array ) );
return array_combine( $keys, array_values( $array ) );
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment