/** * one (of likely many) loops of processing a given * chunk of events * * @param $events */ protected function indexEvents($events) { foreach ($events as $event) { $this->indexer->update($event); } $this->persistenceManager->persistAll(); }
/** * action update * * @param Tx_Contentstage_Domain_Model_Review $review * @param array $reviewers Array of be_user ids * @return void */ public function updateAction(Tx_Contentstage_Domain_Model_Review $review, array $reviewers = array()) { $this->checkPermission(); try { $this->mapReviewers($reviewers, iterator_to_array($review->getReviewed())); } catch (Exception $e) { $this->log->log($this->translate('error.' . $e->getCode(), array($e->getMessage())) ?: $e->getMessage(), Tx_CabagExtbase_Utility_Logging::ERROR); $this->redirect('compare', 'Content'); } // at the moment, it is not possible to inject a storage object at creation, so we have to cheat a bit $tempData = t3lib_div::_GP('tx_contentstage_web_contentstagestage_temp'); if (!$review->getPushPageChanges() && !empty($tempData['review']['dbrecord']) && count($tempData['review']['dbrecord']) > 0) { $converter = $this->objectManager->get('Tx_Contentstage_Property_TypeConverter_DbrecordConverter'); $review->setDbrecord($converter->convertFrom($tempData['review']['dbrecord'], 'Tx_Extbase_Persistence_ObjectStorage<Tx_Contentstage_Domain_Model_Dbrecord>')); } $this->reviewRepository->update($review); $this->persistenceManager->persistAll(); $this->log->log($this->translate('review.update.success'), Tx_CabagExtbase_Utility_Logging::OK); if ($this->reviewConfiguration['autoReviewIfSelf']) { $found = $review->getActiveReviewed($this->activeBackendUser); if ($found !== null && $found->getState() === Tx_Contentstage_Domain_Model_State::FRESH) { // the action will redirect to compare action and thus prevent the initial mail sent and only sends a "changed" mail $this->reviewedAction($review, $this->translate('review.submit.ok'), true); } } $this->sendReviewMailAndLog('changed', $review); $this->redirect('compare', 'Content'); }
/** * action push * * @return void */ public function pushAction() { if ($this->review !== null && $this->review->getUid() > 0) { $this->localRepository->setDepth($this->review->getLevels()); $this->remoteRepository->setDepth($this->review->getLevels()); $this->doComparison(); $changed = $this->review->calculateState(null, false, $this->diff->getMaximumSourceTstamp()); if ($changed) { $this->sendReviewMailAndLog('changed', $this->review); $this->log->log($this->translate('info.review.deprecated'), Tx_CabagExtbase_Utility_Logging::WARNING, $this->diff->getMaximumSourceTstamp()); } } if (!$this->isPushable()) { $this->log->log($this->translate('info.review.noPermission'), Tx_CabagExtbase_Utility_Logging::WARNING); $this->redirect('compare'); } else { // check if by any change there would be some posted records $tempData = t3lib_div::_GP('tx_contentstage_web_contentstagestage_temp'); if (!empty($tempData['review']['dbrecord']) && count($tempData['review']['dbrecord']) > 0) { $converter = $this->objectManager->get('Tx_Contentstage_Property_TypeConverter_DbrecordConverter'); $this->review->setDbrecord($converter->convertFrom($tempData['review']['dbrecord'], 'Tx_Extbase_Persistence_ObjectStorage<Tx_Contentstage_Domain_Model_Dbrecord>')); $this->review->setPushPageChanges(false); } } try { $pageTS = $this->getPageTS(); if (empty($pageTS['doNotSnapshotOnPush'])) { $tables = $this->filterTables(array_keys($this->remoteRepository->getTables()), $this->ignoreSnapshotTables, true); $info = $this->snapshotRepository->create($tables, $this->extensionConfiguration['remote.']['db.'], Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_REMOTE); $this->log->log($this->translate('info.push.snapshot', array($info['file'])), Tx_CabagExtbase_Utility_Logging::OK); } else { $this->log->log($this->translate('info.push.noSnapshot'), Tx_CabagExtbase_Utility_Logging::OK); } $this->pushTables($this->page); $this->log->log($this->translate('info.push.done'), Tx_CabagExtbase_Utility_Logging::OK); // TODO: remove the exception that is thrown when the cache could not be cleared or at least catch it $this->remoteRepository->clearCache($this->page, !!$this->extensionConfiguration['clearAllCaches']); $this->log->log($this->translate('info.push.clearCache'), Tx_CabagExtbase_Utility_Logging::OK); if ($this->review !== null && $this->review->getUid() > 0 && $this->review->getLevels() <= $this->localRepository->getDepth()) { $this->review->addChangeString($this->activeBackendUser, Tx_Contentstage_Domain_Model_State::PUSHED); // reset the domain/page tree cache to allow the values to be rebuilt $this->remoteRepository->clearApplicationCaches(); $this->sendReviewMailAndLog('pushed', $this->review); // once everything is done, persist everything if (!is_object($this->persistenceManager)) { $this->persistenceManager = $this->objectManager->get('\\TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager'); } $this->persistenceManager->persistAll(); } } catch (Exception $e) { $this->log->log($this->translate('error.' . $e->getCode(), array($e->getMessage())) ?: $e->getMessage(), Tx_CabagExtbase_Utility_Logging::ERROR); } $this->log->write(); $this->redirect('compare'); }
/** * destructor * * this will persist all changes */ public function __destruct() { $this->persistenceManager->persistAll(); }