/** * {@inheritdoc} */ public function process(ConsumerEvent $event) { $page = $this->pageManager->findOneBy(array('id' => $event->getMessage()->getValue('pageId'))); if (!$page) { return; } // start a transaction $this->snapshotManager->getConnection()->beginTransaction(); // cleanup snapshots $this->snapshotManager->cleanup($page, $event->getMessage()->getValue('keepSnapshots')); // commit the changes $this->snapshotManager->getConnection()->commit(); }
/** * {@inheritdoc} */ public function process(ConsumerEvent $event) { $pageId = $event->getMessage()->getValue('pageId'); $page = $this->pageManager->findOneBy(array('id' => $pageId)); if (!$page) { return; } // start a transaction $this->snapshotManager->getConnection()->beginTransaction(); // creating snapshot $snapshot = $this->transformer->create($page); // update the page status $page->setEdited(false); $this->pageManager->save($page); // save the snapshot $this->snapshotManager->save($snapshot); $this->snapshotManager->enableSnapshots(array($snapshot)); // commit the changes $this->snapshotManager->getConnection()->commit(); }