public function actionDelete()
 {
     if (!Parameters::hasParam('type')) {
         throw new APIException('Invalid resource TYPE (parameter name: \'type\')', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     if (!Parameters::hasParam('id')) {
         throw new APIException('Invalid resource IDENTIFICATOR (parameter name: \'id\')', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     $type = Parameters::get('type');
     $id = Parameters::get('id');
     return $this->dataAccessor->delete($type, $id);
 }
Example #2
0
 public function actionView()
 {
     if (!Parameters::hasParam('id')) {
         throw new APIException('Invalid resource IDENTIFICATOR (parameter name: \'id\')', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     $id = Parameters::get('id');
     $result = ARUser::model()->findByPk($id);
     if (is_null($result)) {
         throw new APIException('Invalid ID value', APIResponseCode::API_INVALID_ID);
     }
     $coder = new CJSON();
     $response = $coder->encode($result);
     echo $response;
 }
Example #3
0
 private function dispatchCall($controllerName, $method)
 {
     $format = Parameters::hasParam('format') ? Parameters::get('format') : 'json';
     try {
         $controller = $this->getFactory()->createObject($controllerName);
         if (is_null($controller) || !isset($controller)) {
             throw new APIException('Invalid controller name', APIResponseCode::API_INVALID_CLASSNAME);
         }
         if (!method_exists($controller, $method)) {
             throw new APIException('Controller have not the method with specified name', APIResponseCode::API_INVALID_METHOD);
         }
         $controller->{$method}();
     } catch (APIException $ex) {
         Yii::trace($ex, 'apps.APIController');
         die($ex->getResponse($format));
     }
 }
Example #4
0
 public function actionDelete()
 {
     if (!Parameters::hasParam('type')) {
         throw new APIException('Invalid resource TYPE (parameter name: \'type\')', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     if (!Parameters::hasParam('id')) {
         throw new APIException('Invalid resource IDENTIFICATOR (parameter name: \'id\')', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     $type = Parameters::get('type');
     $id = Parameters::get('id');
     $ar = $this->getActiveRecordClass($type);
     $record = $ar::model()->findByPk($id);
     if (!isset($record)) {
         throw new APIException('Invalid ID value', APIResponseCode::API_INVALID_ID);
     }
     if ($record->delete() !== 1) {
         throw new APIException('Could not delete resource object', APIResponseCode::API_SHEMA_DELETE_ERROR);
     }
 }
 public function actionDelete()
 {
     if (!Parameters::hasParam('id')) {
         throw new APIException('Invalid resource IDENTIFICATOR (parameter name: \'id\')', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     try {
         $resource = DataModelFactory::createDataObjectWithType('resource');
         $resource->id = Parameters::get('id');
         $storage = new YiiResourceDataStorage();
         $storage->remove($resource);
     } catch (Exception $e) {
         throw new APIException('Can not save resource object', APIResponseCode::API_SHEMA_CREATE_ERROR);
     }
 }