Ejemplo n.º 1
0
Archivo: Api.php Proyecto: c15k0/psfs
 /**
  * Delete a {__API__}
  *
  * @DELETE
  * @ROUTE /api/{__API__}/{pk}
  *
  * @param string $pk
  *
  * @return \PSFS\base\dto\JsonResponse(data={__API__})
  */
 public function delete($pk = NULL)
 {
     $deleted = FALSE;
     if (NULL !== $pk) {
         try {
             $this->con->beginTransaction();
             $this->hydrateModel($pk);
             if (NULL !== $this->model) {
                 $this->model->delete($this->con);
                 $deleted = TRUE;
             }
         } catch (\Exception $e) {
             Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
         }
     }
     return $this->json(new JsonResponse(NULL, $deleted), $deleted ? 200 : 400);
 }