コード例 #1
0
 /**
  * Reverts an entry to a version.
  *
  * @param EntryVersionModel $version
  *
  * @return bool
  */
 public function revertEntryToVersion(EntryVersionModel $version)
 {
     // If this is a single, we'll have to set the title manually
     if ($version->getSection()->type == SectionType::Single) {
         $version->getContent()->title = $version->getSection()->name;
     }
     // Set the version notes
     $version->revisionNotes = Craft::t('Reverted version {num}.', array('num' => $version->num));
     if (craft()->entries->saveEntry($version)) {
         // Fire an 'onRevertEntryToVersion' event
         $this->onRevertEntryToVersion(new Event($this, array('version' => $version)));
         return true;
     } else {
         return false;
     }
 }