public function __construct(Revision $revision)
 {
     $this->revision = $revision;
     if ($revision->getContentType()) {
         $message = "Not enough privilege the manipulate the object " . $revision->getContentType()->getName() . ":" . $revision->getOuuid();
     } else {
         throw new \Exception("Not enough privilege the manipulate the object");
     }
     parent::__construct($message, 0, null);
 }
Beispiel #2
0
 /**
  * @Route("/data/revisions/revert/{id}", name="revision.revert"))
  * @Method({"POST"})
  */
 public function revertRevisionAction(Revision $revision, Request $request)
 {
     $type = $revision->getContentType()->getName();
     $ouuid = $revision->getOuuid();
     $newestRevision = $this->getNewestRevision($type, $ouuid);
     if ($newestRevision->getDraft()) {
         //TODO: ????
     }
     $revertedRevsision = $this->initNewDraft($type, $ouuid, $revision);
     $this->addFlash('notice', 'Revision ' . $revision->getId() . ' reverted as draft');
     return $this->redirectToRoute('revision.edit', ['revisionId' => $revertedRevsision->getId()]);
 }
Beispiel #3
0
 public function __construct(Revision $revision)
 {
     $this->revision = $revision;
     $message = "Revision " . $revision->getStartTime()->format("c") . " of the object " . $revision->getContentType()->getName() . ":" . $revision->getOuuid() . " is locked by " . $revision->getLockBy() . " until " . $revision->getLockUntil()->format("c");
     parent::__construct($message, 0, null);
 }
 public function findByOuuidContentTypeAndEnvironnement(Revision $revision, Environment $env = null)
 {
     if (!isset($env)) {
         $env = $revision->getContentType()->getEnvironment();
     }
     return $this->findByOuuidAndContentTypeAndEnvironnement($revision->getContentType(), $revision->getOuuid(), $env);
 }
 public function __construct(Revision $revision)
 {
     $this->revision = $revision;
     $message = "Update on a not locked object " . $revision->getContentType()->getName() . ":" . $revision->getOuuid() . ' #' . $revision->getId();
     parent::__construct($message, 0, null);
 }
Beispiel #6
0
 public function createData($ouuid, array $rawdata, ContentType $contentType, $byARealUser = true)
 {
     $now = new \DateTime();
     $until = $now->add(new \DateInterval($byARealUser ? "PT5M" : "PT1M"));
     //+5 minutes
     $newRevision = new Revision();
     $newRevision->setContentType($contentType);
     $newRevision->setOuuid($ouuid);
     $newRevision->setStartTime($now);
     $newRevision->setEndTime(null);
     $newRevision->setDeleted(0);
     $newRevision->setDraft(1);
     $newRevision->setLockBy($this->tokenStorage->getToken()->getUsername());
     $newRevision->setLockUntil($until);
     $newRevision->setRawData($rawdata);
     $em = $this->doctrine->getManager();
     if (!empty($ouuid)) {
         $revisionRepository = $em->getRepository('AppBundle:Revision');
         $anotherObject = $revisionRepository->findOneBy(['contentType' => $contentType, 'ouuid' => $newRevision->getOuuid(), 'endTime' => null]);
         if (!empty($anotherObject)) {
             throw new ConflictHttpException('Duplicate OUUID ' . $ouuid . ' for this content type');
         }
     }
     $em->persist($newRevision);
     $em->flush();
     return $newRevision;
 }