/**
  * Given a certain revision, returns the previous revision.
  *
  * @param AbstractRevision $revision
  * @return AbstractRevision|null null if there is no previous revision
  */
 public function getPrevRevision(AbstractRevision $revision)
 {
     $previousRevisionId = $revision->getPrevRevisionId();
     if (!$previousRevisionId) {
         return null;
     }
     return $this->getRevision($previousRevisionId);
 }
 /**
  * Generate a link to undo the specified revision.  Note that this will only work if
  * that is the most recent content edit against the revision type.
  *
  * @param AbstractRevision $revision The revision to undo.
  * @param Title|null $title The title the revision belongs to
  * @param UUID $workflowId The workflow id the revision belongs to
  * @return Anchor
  * @throws FlowException When the provided revision is not known
  */
 public function undoAction(AbstractRevision $revision, Title $title = null, UUID $workflowId)
 {
     $startId = $revision->getPrevRevisionId();
     $endId = $revision->getRevisionId();
     if ($revision instanceof PostRevision) {
         return $this->undoEditPostAction($title, $workflowId, $startId, $endId);
     } elseif ($revision instanceof Header) {
         return $this->undoEditHeaderAction($title, $workflowId, $startId, $endId);
     } elseif ($revision instanceof PostSummary) {
         return $this->undoEditSummaryAction($title, $workflowId, $startId, $endId);
     } else {
         throw new FlowException('Unknown revision type: ' . get_class($revision));
     }
 }
 /**
  * Retrieves the previous revision for a given AbstractRevision
  * @param  AbstractRevision $revision The revision to retrieve the previous revision for.
  * @return AbstractRevision|null      AbstractRevision of the previous revision or null if no previous revision.
  */
 protected function getPreviousRevision(AbstractRevision $revision)
 {
     $previousRevisionId = $revision->getPrevRevisionId();
     // original post; no previous revision
     if ($previousRevisionId === null) {
         return null;
     }
     if (!isset($this->revisionCache[$previousRevisionId->getAlphadecimal()])) {
         $this->revisionCache[$previousRevisionId->getAlphadecimal()] = $this->storage->get('PostRevision', $previousRevisionId);
     }
     return $this->revisionCache[$previousRevisionId->getAlphadecimal()];
 }