From 4ef735b297f269a0f191d63ac216f0f596f92721 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 17 Jul 2012 15:54:02 -0400 Subject: [PATCH] Progress on displaying individual lists (not fully functional yet due to isset bug in ZF2's AbstractRowGateway). --- .../VuFind/src/VuFind/Db/Table/UserList.php | 27 ++++++++++--------- .../src/VuFind/Search/Favorites/Results.php | 5 ++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/module/VuFind/src/VuFind/Db/Table/UserList.php b/module/VuFind/src/VuFind/Db/Table/UserList.php index ee3a9a1ce24..1a1c2db9a59 100644 --- a/module/VuFind/src/VuFind/Db/Table/UserList.php +++ b/module/VuFind/src/VuFind/Db/Table/UserList.php @@ -26,6 +26,8 @@ * @link http://www.vufind.org Main Page */ namespace VuFind\Db\Table; +use VuFind\Exception\LoginRequired as LoginRequiredException, + VuFind\Exception\RecordMissing as RecordMissingException; /** * Table Definition for user_list @@ -52,20 +54,20 @@ class UserList extends Gateway * @param VuFind_Model_Db_UserListRow $user User object representing owner of * new list * - * @return VuFind_Model_Db_UserListRow + * @return \VuFind\Db\Row\UserList + * @throws LoginRequiredException */ public static function getNew($user) { - /* TODO if (!$user) { - throw new VF_Exception_LoginRequired('Log in to create lists.'); + throw new LoginRequiredException('Log in to create lists.'); } - $table = new VuFind_Model_Db_UserList(); - $row = $table->createRow(); + $class = get_called_class(); + $table = new $class(); + $row = clone($table->getResultSetPrototype()->getArrayObjectPrototype()); $row->user_id = $user->id; return $row; - */ } /** @@ -73,19 +75,18 @@ class UserList extends Gateway * * @param int $id Numeric ID for existing list. * - * @return VuFind_Model_Db_UserListRow - * @throws VF_Exception_RecordMissing + * @return \VuFind\Db\Row\UserList + * @throws RecordMissingException */ public static function getExisting($id) { - /* TODO - $table = new VuFind_Model_Db_UserList(); - $result = $table->find($id)->current(); + $class = get_called_class(); + $table = new $class(); + $result = $table->select(array('id' => $id))->current(); if (is_null($result)) { - throw new VF_Exception_RecordMissing('Cannot load list ' . $id); + throw new RecordMissingException('Cannot load list ' . $id); } return $result; - */ } /** diff --git a/module/VuFind/src/VuFind/Search/Favorites/Results.php b/module/VuFind/src/VuFind/Search/Favorites/Results.php index a1f6c2981a5..62b8537c28c 100644 --- a/module/VuFind/src/VuFind/Search/Favorites/Results.php +++ b/module/VuFind/src/VuFind/Search/Favorites/Results.php @@ -27,6 +27,7 @@ */ namespace VuFind\Search\Favorites; use VuFind\Db\Table\Resource as ResourceTable, + VuFind\Db\Table\UserList as UserListTable, VuFind\Exception\ListPermission as ListPermissionException, VuFind\Record, VuFind\Search\Base\Results as BaseResults, @@ -205,7 +206,7 @@ class Results extends BaseResults * Get the list object associated with the current search (null if no list * selected). * - * @return VuFind_Model_Db_UserListRow|null + * @return \VuFind\Db\Row\UserList|null */ public function getListObject() { @@ -216,7 +217,7 @@ class Results extends BaseResults $filters = $this->params->getFilters(); $listId = isset($filters['lists'][0]) ? $filters['lists'][0] : null; $this->list = is_null($listId) - ? null : VuFind_Model_Db_UserList::getExisting($listId); + ? null : UserListTable::getExisting($listId); } return $this->list; } -- GitLab