Exemplo n.º 1
0
 public function actionCreate()
 {
     $storage = new YiiUserDataStorage();
     if (is_null($storage)) {
         throw new APIException('Could not create data storage', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     try {
         $obj = new User();
         $data = Parameters::getRaw('data', 'post');
         $attr = $storage->decodeResponse($data);
         $obj->setAttributes($attr);
         $storage->save($obj);
     } catch (Exception $e) {
         throw new APIException('Can not save resource object', APIResponseCode::API_SHEMA_CREATE_ERROR);
     }
 }
 public function actionUpdate()
 {
     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);
     }
     if (!Parameters::hasParam('data')) {
         throw new APIException('Invalid resource IDENTIFICATOR (parameter name: \'data\')', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     $type = Parameters::get('type');
     $data = Parameters::getRaw('data', 'post');
     // Should use decoder
     $attributes = $data;
     return $this->dataAccessor->save($type, $attributes);
 }
Exemplo n.º 3
0
 public function actionCreate()
 {
     if (!Parameters::hasParam('type')) {
         throw new APIException('Invalid resource TYPE (parameter name: \'type\')', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     $type = Parameters::get('type');
     $storage = DataStorageFactory::createStorage($type);
     if (is_null($storage)) {
         throw new APIException('Could not create data storage', APIResponseCode::API_INVALID_METHOD_PARAMS);
     }
     try {
         $obj = DataModelFactory::createDataObjectWithType($type);
         $data = Parameters::getRaw('data', 'post');
         $attr = $storage->decodeResponse($data);
         $obj->setAttributes($attr);
         $storage->save($obj);
     } catch (Exception $e) {
         throw new APIException('Can not save resource object', APIResponseCode::API_SHEMA_CREATE_ERROR);
     }
 }
Exemplo n.º 4
0
 public static function get($param_name, $type = 'GET')
 {
     $arg_val = Parameters::getRaw($param_name, $type);
     return mysql_escape_string($arg_val);
 }
Exemplo n.º 5
0
 public function actionCreate()
 {
     try {
         $obj = DataModelFactory::createDataObjectWithType('resource');
         $data = Parameters::getRaw('data', 'post');
         $storage = new YiiResourceDataStorage();
         $attr = $storage->decodeResponse($data);
         $obj->setAttributes($attr);
         $storage->save($obj);
     } catch (Exception $e) {
         throw new APIException('Can not save resource object', APIResponseCode::API_SHEMA_CREATE_ERROR);
     }
 }