/**
  * Overrides the standard resolveView method
  *
  * @return \TYPO3\Flow\Mvc\View\ViewInterface $view The view
  */
 protected function resolveView()
 {
     $view = new \TYPO3\Fluid\View\TemplateView();
     $view->setControllerContext($this->controllerContext);
     $view->setTemplatePathAndFilename(FLOW_PATH_FLOW . 'Resources/Private/Mvc/StandardView_Template.html');
     return $view;
 }
 /**
  * Saves the translations from the translation form
  *
  * @param string $packageKey
  * @param string $fromLang
  * @param string $toLang
  * @param array $translationUnits
  */
 public function saveTranslationsAction($packageKey, $fromLang, $toLang, array $translationUnits)
 {
     $originalMatrix = $this->generateTranslationMatrix($packageKey, $fromLang, $toLang);
     $matrixToSave = array();
     foreach ($translationUnits as $translationUnit => $value) {
         if (isset($value[$toLang]) && $value[$toLang] != '') {
             $matrixToSave[$translationUnit] = $originalMatrix[$translationUnit];
             if (isset($matrixToSave[$translationUnit]['target'])) {
                 $matrixToSave[$translationUnit]['oldTarget'] = $matrixToSave[$translationUnit]['target'];
             }
             $matrixToSave[$translationUnit]['target'] = $value[$toLang];
         }
     }
     // Create the Xliff file to be written to disk later on
     $xliffView = new \TYPO3\Fluid\View\TemplateView();
     $path = 'resource://Mrimann.XliffTranslator/Private/Templates/Standard/Xliff.xlf';
     $xliffView->setControllerContext($this->getControllerContext());
     $xliffView->setTemplatePathAndFilename($path);
     $xliffView->assign('matrixToSave', $matrixToSave);
     // backup the original file before overwriting
     $this->backupXliffFile($packageKey, $toLang);
     // check if the file exists (or create an empty file in case these are the first translations)
     if (!is_dir(dirname($this->getFilePath($packageKey, $toLang)))) {
         mkdir(dirname($this->getFilePath($packageKey, $toLang)));
     }
     if (!is_file($this->getFilePath($packageKey, $toLang))) {
         touch($this->getFilePath($packageKey, $toLang));
     }
     // write the file
     $outputPath = $this->getFilePath($packageKey, $toLang);
     file_put_contents($outputPath, $xliffView->render());
     // redirect the user back to the translation page
     $this->addFlashMessage('Your translations were successfully saved!', 'Yippie!', 'OK');
     $this->redirect('translate', 'Standard', 'Mrimann.XliffTranslator', array('packageKey' => $packageKey, 'fromLang' => $fromLang, 'toLang' => $toLang));
 }