Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for number of users per page (pagination) #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/ZfcUserAdmin.global.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ $settings = array(
* ZfcUserAdmin\Mapper\UserZendDb
*/
'user_mapper' => 'ZfcUserAdmin\Mapper\UserDoctrine',

/**
* Users per page
*
* Specify the number of user which will display per page.
* Default is 100 users per page.
*/
// 'userCountPerPage' => 100,
);

/**
Expand Down
3 changes: 2 additions & 1 deletion src/ZfcUserAdmin/Controller/UserAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public function listAction()
$paginator = $users;
}

$paginator->setItemCountPerPage(100);
$userCountPerPage = $this->getOptions()->getUserCountPerPage();
$paginator->setItemCountPerPage($userCountPerPage);
$paginator->setCurrentPageNumber($this->getEvent()->getRouteMatch()->getParam('p'));
return array(
'users' => $paginator,
Expand Down
14 changes: 14 additions & 0 deletions src/ZfcUserAdmin/Options/ModuleOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class ModuleOptions extends AbstractOptions implements
* Allow change user password on user edit form.
*/
protected $allowPasswordChange = true;

/**
* @var int
* Count users show per page
*/
protected $userCountPerPage = 100;

protected $userMapper = 'ZfcUserAdmin\Mapper\UserDoctrine';

Expand Down Expand Up @@ -109,4 +115,12 @@ public function setAdminPasswordChange($allowPasswordChange)
{
$this->allowPasswordChange = $allowPasswordChange;
}

public function getUserCountPerPage() {
return $this->userCountPerPage;
}

public function setUserCountPerPage($UserCountPerPage) {
$this->userCountPerPage = (int) $UserCountPerPage;
}
}
6 changes: 5 additions & 1 deletion src/ZfcUserAdmin/Options/UserListOptionsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ interface UserListOptionsInterface
public function getUserListElements();

public function setUserListElements(array $elements);
}

public function getUserCountPerPage();

public function setUserCountPerPage($UserCountPerPage);
}