Skip to content
Snippets Groups Projects
Commit 4ef735b2 authored by Demian Katz's avatar Demian Katz
Browse files

Progress on displaying individual lists (not fully functional yet due to isset...

Progress on displaying individual lists (not fully functional yet due to isset bug in ZF2's AbstractRowGateway).
parent ad7167b9
No related merge requests found
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @link http://www.vufind.org Main Page * @link http://www.vufind.org Main Page
*/ */
namespace VuFind\Db\Table; namespace VuFind\Db\Table;
use VuFind\Exception\LoginRequired as LoginRequiredException,
VuFind\Exception\RecordMissing as RecordMissingException;
/** /**
* Table Definition for user_list * Table Definition for user_list
...@@ -52,20 +54,20 @@ class UserList extends Gateway ...@@ -52,20 +54,20 @@ class UserList extends Gateway
* @param VuFind_Model_Db_UserListRow $user User object representing owner of * @param VuFind_Model_Db_UserListRow $user User object representing owner of
* new list * new list
* *
* @return VuFind_Model_Db_UserListRow * @return \VuFind\Db\Row\UserList
* @throws LoginRequiredException
*/ */
public static function getNew($user) public static function getNew($user)
{ {
/* TODO
if (!$user) { 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(); $class = get_called_class();
$row = $table->createRow(); $table = new $class();
$row = clone($table->getResultSetPrototype()->getArrayObjectPrototype());
$row->user_id = $user->id; $row->user_id = $user->id;
return $row; return $row;
*/
} }
/** /**
...@@ -73,19 +75,18 @@ class UserList extends Gateway ...@@ -73,19 +75,18 @@ class UserList extends Gateway
* *
* @param int $id Numeric ID for existing list. * @param int $id Numeric ID for existing list.
* *
* @return VuFind_Model_Db_UserListRow * @return \VuFind\Db\Row\UserList
* @throws VF_Exception_RecordMissing * @throws RecordMissingException
*/ */
public static function getExisting($id) public static function getExisting($id)
{ {
/* TODO $class = get_called_class();
$table = new VuFind_Model_Db_UserList(); $table = new $class();
$result = $table->find($id)->current(); $result = $table->select(array('id' => $id))->current();
if (is_null($result)) { if (is_null($result)) {
throw new VF_Exception_RecordMissing('Cannot load list ' . $id); throw new RecordMissingException('Cannot load list ' . $id);
} }
return $result; return $result;
*/
} }
/** /**
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
*/ */
namespace VuFind\Search\Favorites; namespace VuFind\Search\Favorites;
use VuFind\Db\Table\Resource as ResourceTable, use VuFind\Db\Table\Resource as ResourceTable,
VuFind\Db\Table\UserList as UserListTable,
VuFind\Exception\ListPermission as ListPermissionException, VuFind\Exception\ListPermission as ListPermissionException,
VuFind\Record, VuFind\Record,
VuFind\Search\Base\Results as BaseResults, VuFind\Search\Base\Results as BaseResults,
...@@ -205,7 +206,7 @@ class Results extends BaseResults ...@@ -205,7 +206,7 @@ class Results extends BaseResults
* Get the list object associated with the current search (null if no list * Get the list object associated with the current search (null if no list
* selected). * selected).
* *
* @return VuFind_Model_Db_UserListRow|null * @return \VuFind\Db\Row\UserList|null
*/ */
public function getListObject() public function getListObject()
{ {
...@@ -216,7 +217,7 @@ class Results extends BaseResults ...@@ -216,7 +217,7 @@ class Results extends BaseResults
$filters = $this->params->getFilters(); $filters = $this->params->getFilters();
$listId = isset($filters['lists'][0]) ? $filters['lists'][0] : null; $listId = isset($filters['lists'][0]) ? $filters['lists'][0] : null;
$this->list = is_null($listId) $this->list = is_null($listId)
? null : VuFind_Model_Db_UserList::getExisting($listId); ? null : UserListTable::getExisting($listId);
} }
return $this->list; return $this->list;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment