/** * Converts a accordingly formatted, associative array to a change collection * * @param array $source * @param string $targetType not used * @param array $subProperties not used * @param \TYPO3\Flow\Property\PropertyMappingConfigurationInterface $configuration not used * @return mixed An object or \TYPO3\Flow\Error\Error if the input format is not supported or could not be converted for other reasons * @throws \Exception */ public function convertFrom($source, $targetType, array $subProperties = array(), PropertyMappingConfigurationInterface $configuration = null) { if (!is_array($source)) { return new \TYPO3\Flow\Error\Error(sprintf('Cannot convert %s to ChangeCollection.', gettype($source))); } $changeCollection = new ChangeCollection(); foreach ($source as $changeData) { $convertedData = $this->convertChangeData($changeData); if ($convertedData instanceof \TYPO3\Flow\Error\Error) { return $convertedData; } $changeCollection->add($convertedData); } return $changeCollection; }
/** * Apply a set of changes to the system * * @param ChangeCollection $changes * @return void */ public function changeAction(ChangeCollection $changes) { try { $count = $changes->count(); $changes->compress()->apply(); $success = new Info(); $success->setMessage(sprintf('%d change(s) successfully applied.', $count)); $this->feedbackCollection->add($success); $this->persistenceManager->persistAll(); } catch (\Exception $e) { $error = new Error(); $error->setMessage($e->getMessage()); $this->feedbackCollection->add($error); } $this->view->assign('value', $this->feedbackCollection); }