/** * Updates a trans unit from the request. * * @param integer $id * @param Request $request * @throws NotFoundHttpException * @return \Lexik\Bundle\TranslationBundle\Model\TransUnit */ public function updateFromRequest($id, Request $request) { $transUnit = $this->storage->getTransUnitById($id); if (!$transUnit) { throw new NotFoundHttpException(sprintf('No TransUnit found for "%s"', $id)); } $translationsContent = array(); foreach ($this->managedLoales as $locale) { $translationsContent[$locale] = $request->request->get($locale); } $this->transUnitManager->updateTranslationsContent($transUnit, $translationsContent); if ($transUnit instanceof TransUnitDocument) { $transUnit->convertMongoTimestamp(); } $this->storage->flush(); return $transUnit; }