From 50fd7ef1176d37d12eb53150f21df9f70c5e55c7 Mon Sep 17 00:00:00 2001 From: Brendon Kozlowski Date: Wed, 23 Aug 2017 15:05:00 -0400 Subject: [PATCH] Add cover_image_file_id to API data Adds to the response data from the API, allowing the exhibit record's cover image file id to be exposed. --- models/Api/Exhibit.php | 79 +++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/models/Api/Exhibit.php b/models/Api/Exhibit.php index 0980c584..37a0f466 100644 --- a/models/Api/Exhibit.php +++ b/models/Api/Exhibit.php @@ -1,39 +1,40 @@ -id; - $representation['title'] = $record->title; - $representation['url'] = self::getResourceUrl("/exhibits/{$record->id}"); - $representation['slug'] = $record->slug; - $representation['description'] = $record->description; - $representation['credits'] = $record->credits; - $representation['featured'] = (bool) $record->featured; - $representation['public'] = (bool) $record->public; - $representation['added'] = self::getDate($record->added); - $representation['modified'] = self::getDate($record->modified); - $representation['owner'] = array( - 'id' => $record->owner_id, - 'resource' => 'users', - 'url' => self::getResourceUrl("/users/{$record->owner_id}") - ); - $pageCount = get_db()->getTable('ExhibitPage')->count(array('exhibit'=>$record->id)); - $representation['pages'] = array( - 'count' => $pageCount, - 'resource' => 'exhibit_pages', - 'url' => self::getResourceUrl("/exhibit_pages?exhibit={$record->id}") - ); - return $representation; - } - - public function getResourceId() - { - return "ExhibitBuilder_Exhibits"; - } - +id; + $representation['title'] = $record->title; + $representation['url'] = self::getResourceUrl("/exhibits/{$record->id}"); + $representation['slug'] = $record->slug; + $representation['description'] = $record->description; + $representation['credits'] = $record->credits; + $representation['featured'] = (bool) $record->featured; + $representation['public'] = (bool) $record->public; + $representation['cover_image_file_id'] = $record->cover_image_file_id; + $representation['added'] = self::getDate($record->added); + $representation['modified'] = self::getDate($record->modified); + $representation['owner'] = array( + 'id' => $record->owner_id, + 'resource' => 'users', + 'url' => self::getResourceUrl("/users/{$record->owner_id}") + ); + $pageCount = get_db()->getTable('ExhibitPage')->count(array('exhibit'=>$record->id)); + $representation['pages'] = array( + 'count' => $pageCount, + 'resource' => 'exhibit_pages', + 'url' => self::getResourceUrl("/exhibit_pages?exhibit={$record->id}") + ); + return $representation; + } + + public function getResourceId() + { + return "ExhibitBuilder_Exhibits"; + } + // Set data to a record during a POST request. public function setPostData(Omeka_Record_AbstractRecord $record, $data) { @@ -44,6 +45,6 @@ public function setPostData(Omeka_Record_AbstractRecord $record, $data) public function setPutData(Omeka_Record_AbstractRecord $record, $data) { // Set properties directly to an existing record. - } - -} \ No newline at end of file + } + +}