/** * Save book editors with a publication * * @param string $event the name of the event * @param string $type the type of the event * @param \Publication $entity supplied entity * * @return void */ public static function saveBookEditors($event, $type, $entity) { if (!$entity instanceof \Publication) { return; } // cleanup book editors $entity->deleteRelationships('book_editor'); unset($entity->book_editors); $supported_types = ['book', 'inbook', 'incollection', 'proceedings', 'inproceedings']; $type = get_input('type'); if (!in_array($type, $supported_types)) { return; } $book_editors_guids = get_input('book_editors'); $book_editors_order = get_input('book_editors_order'); // save book editors if (!empty($book_editors_guids)) { foreach ($book_editors_guids as $book_editor) { add_entity_relationship($entity->getGUID(), 'book_editor', $book_editor); } } $pbook_editors = implode(',', $book_editors_order); $entity->book_editors = $pbook_editors; $entity->save(); }