/** * Update user revision. * * @param Revision $revision * * @return Revision * @throws ClassContentException Occurs on illegal revision state */ public function update(Revision $revision) { switch ($revision->getState()) { case Revision::STATE_ADDED: throw new ClassContentException('Content is not versioned yet', ClassContentException::REVISION_ADDED); break; case Revision::STATE_MODIFIED: try { $this->checkContent($revision); throw new ClassContentException('Content is already up-to-date', ClassContentException::REVISION_UPTODATE); } catch (ClassContentException $e) { if (ClassContentException::REVISION_OUTOFDATE == $e->getCode()) { return $this->loadSubcontents($revision); } else { throw $e; } } break; case Revision::STATE_CONFLICTED: throw new ClassContentException('Content is in conflict, resolve or revert it', ClassContentException::REVISION_CONFLICTED); break; } throw new ClassContentException('Content is already up-to-date', ClassContentException::REVISION_UPTODATE); }