コード例 #1
0
ファイル: BaseAdmin.php プロジェクト: pablozabo/Diarco
 static function createTestimonio($testimonioDto)
 {
     $testimonio = new Testimonio(NULL, date("Y-m-d H:i:s", time()), TRUE, $testimonioDto->nombre, $testimonioDto->apellido, $testimonioDto->ciudad, $testimonioDto->testimonio, $testimonioDto->img);
     $transaction = NULL;
     $result = new Result();
     try {
         $transaction = GenericDao::beginTransaction();
         $testimonio->id = $testimonioId = BaseDao::createTestimonio($testimonio, $transaction);
         if (FileManager::fileLoaded()) {
             $testimonio->img = 'testimonio_' . $testimonioId . "." . FileManager::getFileExtension();
             BaseDao::updateTestimonio($testimonio, $transaction);
             FileManager::saveFile('testimonios', 'testimonio', $testimonioId);
         }
         $transaction->commit();
     } catch (\Exception $ex) {
         $transaction->rollBack();
         $result->hasErrors = true;
         $result->messages = array($ex->getMessage());
     }
     $response = new Response($result, NULL);
     return json_encode($response);
 }