/** * Publishes a draft. * * @param EntryDraftModel $draft * * @return bool */ public function publishDraft(EntryDraftModel $draft) { // If this is a single, we'll have to set the title manually if ($draft->getSection()->type == SectionType::Single) { $draft->getContent()->title = $draft->getSection()->name; } // Set the version notes if (!$draft->revisionNotes) { $draft->revisionNotes = Craft::t('Published draft “{name}”.', array('name' => $draft->name)); } if (craft()->entries->saveEntry($draft)) { // Fire an 'onPublishDraft' event $this->onPublishDraft(new Event($this, array('draft' => $draft))); $this->deleteDraft($draft); return true; } else { return false; } }