Skip to content

Instantly share code, notes, and snippets.

@tankist

tankist/php

Created May 4, 2011
Embed
What would you like to do?
Collection pagination example
class Model_Mapper_Db_User extends Skaya_Model_Mapper_Db_Abstract {
public function getUsersPaginator($order = null) {
$userTable = self::_getTableByName(self::TABLE_NAME);
$select = $userTable->select();
if ($order) {
$select->order($this->_mapOrderStatement($order));
}
$paginator = Skaya_Paginator::factory($select, 'DbSelect');
$paginator->addFilter(new Zend_Filter_Callback(array(
'callback' => array($this, 'getMappedArrayFromData')
)));
return $paginator;
}
}
class Service_User extends Skaya_Model_Service_Abstract {
public function getUsersPaginator($order = null) {
$paginator = $this->_mappers->user->getUsersPaginator($order);
$paginator->addFilter(new Skaya_Filter_Array_Collection('Model_Collection_Users'));
return $paginator;
}
}
class Model_Collection_Users extends Skaya_Model_Collection_Abstract {
protected $_itemType = 'Model_User';
}
$paginator = Skaya_Model_Service_Abstract::factory('User')->getUsersPaginator();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment