本文整理汇总了PHP中Draft::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Draft::create方法的具体用法?PHP Draft::create怎么用?PHP Draft::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Draft
的用法示例。
在下文中一共展示了Draft::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createDraft
function _createDraft($vars)
{
$field_list = array('response', 'note', 'answer', 'body', 'message', 'issue');
foreach ($field_list as $field) {
if (isset($_POST[$field])) {
$vars['body'] = urldecode($_POST[$field]);
break;
}
}
if (!isset($vars['body'])) {
return Http::response(422, "Draft body not found in request");
}
$errors = array();
if (!($draft = Draft::create($vars, $errors))) {
Http::response(500, print_r($errors, true));
}
// If the draft is created from an existing document, ensure inline
// attachments from the cloned document are attachned to the draft
// XXX: Actually, I think this is just wasting time, because the
// other object already has the items attached, so the database
// won't clean up the files. They don't have to be attached to
// the draft for Draft::getAttachmentIds to return the id of the
// attached file
//$draft->syncExistingAttachments();
echo JsonDataEncoder::encode(array('draft_id' => $draft->getId()));
}
示例2: create_draft
/**
* save the proposal as a draft
*/
public function create_draft() {
$draft = new Draft;
$draft->proposal = $this->id;
$draft->title = $this->title;
$draft->content = $this->content;
$draft->reason = $this->reason;
if (Login::$member) {
$draft->author = Login::$member->id;
} else {
// admin
$draft->author = null;
}
$draft->create();
}