Skip to content

Commit

Permalink
Revert "Add a "convert_ids" parameter to Item_Model::as_restful_array…
Browse files Browse the repository at this point in the history
…(), which"

This reverts commit 98fce83.

Conflicts:

	modules/gallery/tests/Item_Model_Test.php
  • Loading branch information
bharat committed Jun 16, 2010
1 parent 57b53e6 commit e353534
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
20 changes: 8 additions & 12 deletions modules/gallery/models/item.php
Expand Up @@ -924,21 +924,17 @@ public function read_only(Validation $v, $field) {
/**
* Same as ORM::as_array() but convert id fields into their RESTful form.
*/
public function as_restful_array($convert_ids=true) {
public function as_restful_array() {
// Convert item ids to rest URLs for consistency
$data = $this->as_array();

if ($convert_ids) {
if ($tmp = $this->parent()) {
$data["parent"] = rest::url("item", $tmp);
}
unset($data["parent_id"]);

if ($tmp = $this->album_cover()) {
$data["album_cover"] = rest::url("item", $tmp);
}
unset($data["album_cover_item_id"]);
if ($tmp = $this->parent()) {
$data["parent"] = rest::url("item", $tmp);
}
unset($data["parent_id"]);
if ($tmp = $this->album_cover()) {
$data["album_cover"] = rest::url("item", $tmp);
}
unset($data["album_cover_item_id"]);

if (access::can("view_full", $this) && $this->is_photo()) {
$data["file_url"] = $this->file_url(true);
Expand Down
12 changes: 0 additions & 12 deletions modules/gallery/tests/Item_Model_Test.php
Expand Up @@ -368,18 +368,6 @@ public function as_restful_array_test() {
$this->assert_true(!array_key_exists("album_cover_item_id", $result));
}

public function as_restful_array_with_ids_test() {
$album = test::random_album();
$photo = test::random_photo($album);
$album->reload();

$result = $album->as_restful_array(false);
$this->assert_same(item::root()->id, $result["parent_id"]);
$this->assert_same($photo->id, $result["album_cover_item_id"]);
$this->assert_true(!array_key_exists("parent", $result));
$this->assert_true(!array_key_exists("album_cover_item", $result));
}

public function as_restful_array_with_edit_bit_test() {
$response = item::root()->as_restful_array(true);
$this->assert_true($response["can_edit"]);
Expand Down

0 comments on commit e353534

Please sign in to comment.