示例#1
0
 public function execute($id)
 {
     $app = \App::getInstance();
     $em = new \Archive\Port\Adaptor\Persistence\PDO\DocumentEntityManager();
     if ($doc = $em->findById($id)) {
         return $doc;
     } else {
         $app->throwError(new \Exception("Document {$id} not found", 404));
     }
 }
示例#2
0
 public function execute($id)
 {
     $app = \App::getInstance();
     $em = new \Archive\Port\Adaptor\Persistence\PDO\DocumentEntityManager();
     if ($doc = $em->findById($id)) {
         try {
             $conn = $app->DB_CONNECT;
             $conn->beginTransaction();
             $doc = $em->patch($app->REQUEST, $doc);
             $conn->commit();
             return $doc;
         } catch (\Exception $e) {
             $conn->rollback();
             $app->throwError($e);
         }
     } else {
         $app->throwError(new \Exception("Document \"{$id}\" not found", 404));
     }
 }