Ejemplo n.º 1
0
 /**
  * Returns a revision.
  *
  * @return Symfony\Component\HttpFoundation\JsonResponse
  *
  * @Rest\ParamConverter(name="revision", class="BackBee\ClassContent\Revision")
  * @Rest\Security("is_fully_authenticated() & has_role('ROLE_API_USER')")
  */
 public function getAction(Revision $revision)
 {
     $this->granted('VIEW', $revision->getContent());
     $response = $this->createJsonResponse();
     $response->setData($revision->jsonSerialize(Revision::JSON_REVISION_FORMAT));
     return $response;
 }
Ejemplo n.º 2
0
 /**
  * Checks the content state of a revision.
  *
  * @param Revision $revision
  *
  * @return AbstractClassContent  the valid content according to revision state
  * @throws ClassContentException Occurs when the revision is orphan
  */
 private function checkContent(Revision $revision)
 {
     $content = $revision->getContent();
     if (null === $content || !$content instanceof AbstractClassContent) {
         $this->_em->remove($revision);
         throw new ClassContentException('Orphan revision, deleted', ClassContentException::REVISION_ORPHAN);
     }
     if ($revision->getRevision() != $content->getRevision()) {
         throw new ClassContentException('Content is out of date', ClassContentException::REVISION_OUTOFDATE);
     }
     return $content;
 }