Updated to reflect the fact that "resource" is now "entity" in responses.
This commit is contained in:
parent
8bd90d145d
commit
eae41b182d
|
@ -27,7 +27,7 @@ class Gallery3 {
|
|||
var $data;
|
||||
var $file;
|
||||
|
||||
protected $original_resource;
|
||||
protected $original_entity;
|
||||
|
||||
/**
|
||||
* Connect to a remote Gallery3 instance
|
||||
|
@ -77,7 +77,7 @@ class Gallery3 {
|
|||
* @chainable
|
||||
*/
|
||||
public function set($key, $value) {
|
||||
$this->data->resource->$key = $value;
|
||||
$this->data->entity->$key = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class Gallery3 {
|
|||
*/
|
||||
public function create($url, $token) {
|
||||
$response = Gallery3_Helper::request(
|
||||
"post", $url, $token, $this->data->resource, $this->file);
|
||||
"post", $url, $token, $this->data->entity, $this->file);
|
||||
$this->url = $response->url;
|
||||
$this->token = $token;
|
||||
return $this->load();
|
||||
|
@ -115,7 +115,7 @@ class Gallery3 {
|
|||
public function save() {
|
||||
$response = Gallery3_Helper::request(
|
||||
"put", $this->url, $this->token,
|
||||
array_diff($this->original_resource, (array)$this->data->resource));
|
||||
array_diff($this->original_entity, (array)$this->data->entity));
|
||||
return $this->load();
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class Gallery3 {
|
|||
public function load() {
|
||||
$response = Gallery3_Helper::request("get", $this->url, $this->token);
|
||||
$this->data = $response;
|
||||
$this->original_resource = (array)$response->resource;
|
||||
$this->original_entity = (array)$response->entity;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ $album = Gallery3::factory()
|
|||
->set("name", "Sample Album")
|
||||
->set("title", "This is my Sample Album")
|
||||
->create($root->url, $auth);
|
||||
alert("Created album: <b>{$album->url} {$album->data->resource->title}</b>");
|
||||
alert("Created album: <b>{$album->url} {$album->data->entity->title}</b>");
|
||||
|
||||
|
||||
alert("Modify the album");
|
||||
$album
|
||||
->set("title", "This is the new title")
|
||||
->save();
|
||||
alert("New title: <b>{$album->data->resource->title}</b>");
|
||||
alert("New title: <b>{$album->data->entity->title}</b>");
|
||||
|
||||
|
||||
$photo = Gallery3::factory()
|
||||
|
|
Reference in New Issue
Block a user