本文整理汇总了PHP中Publication::deleteRelationships方法的典型用法代码示例。如果您正苦于以下问题:PHP Publication::deleteRelationships方法的具体用法?PHP Publication::deleteRelationships怎么用?PHP Publication::deleteRelationships使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publication
的用法示例。
在下文中一共展示了Publication::deleteRelationships方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveBookEditors
/**
* 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();
}