Esempio n. 1
0
 $data = $RestServer->getServerData();
 if ('corps' === $resource) {
     $corps = new Corps();
     $results = null;
     if ($verb === 'GET') {
         if ($id === NULL) {
             $results = $corps->getAll();
         } else {
             $results = $corps->get($id);
         }
     }
     if ($verb === 'PUT') {
         if ($id === NULL) {
             throw new InvalidArgumentException('Corporation ID ' . $id . ' was not found');
         } else {
             $results = $corps->put($data, $id);
             $RestServer->setMessage($id . ' updated');
         }
     }
     if ($verb === 'POST') {
         if ($corps->post($data)) {
             $RestServer->setMessage('Corporation  Added');
             $RestServer->setStatus(201);
         } else {
             throw new Exception('Corporation not added');
         }
     }
     if ($verb === 'DELETE') {
         if ($id === NULL) {
             throw new InvalidArgumentException('No ID');
         } else {