Beispiel #1
0
 public function __invoke(Request $req, Response $res)
 {
     $school = $req->getAttribute('school', false);
     if (!$school->id) {
         return $res->withStatus(403, 'No school');
     }
     $id = $req->getParam('id', false);
     if (!$id) {
         $res = $res->withStatus(404);
         return $res;
     }
     $software = $this->softwareService->getSoftwareById($id);
     if ($software['school_id'] != $school->id) {
         $res = $res->withStatus(403, 'Schools not match');
         return $res;
     }
     try {
         $this->softwareService->removeSoftware($id);
         $res = $res->withStatus(204);
     } catch (Exception $ex) {
         $res = $res->withStatus(500, $ex->getMessage());
     }
     return $res;
 }