From ec3739abba2981fdfc89b1a634fb7a0c01dc929b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20W=C3=BCthrich?= Date: Fri, 15 Aug 2014 01:30:37 +0200 Subject: [PATCH] Add option for number of users per page (pagination) --- config/ZfcUserAdmin.global.php.dist | 8 ++++++++ .../Controller/UserAdminController.php | 3 ++- src/ZfcUserAdmin/Options/ModuleOptions.php | 14 ++++++++++++++ .../Options/UserListOptionsInterface.php | 6 +++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/config/ZfcUserAdmin.global.php.dist b/config/ZfcUserAdmin.global.php.dist index bdc964b..dd41379 100644 --- a/config/ZfcUserAdmin.global.php.dist +++ b/config/ZfcUserAdmin.global.php.dist @@ -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, ); /** diff --git a/src/ZfcUserAdmin/Controller/UserAdminController.php b/src/ZfcUserAdmin/Controller/UserAdminController.php index 4671f0b..492d076 100644 --- a/src/ZfcUserAdmin/Controller/UserAdminController.php +++ b/src/ZfcUserAdmin/Controller/UserAdminController.php @@ -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, diff --git a/src/ZfcUserAdmin/Options/ModuleOptions.php b/src/ZfcUserAdmin/Options/ModuleOptions.php index db86df9..b75a463 100644 --- a/src/ZfcUserAdmin/Options/ModuleOptions.php +++ b/src/ZfcUserAdmin/Options/ModuleOptions.php @@ -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'; @@ -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; + } } diff --git a/src/ZfcUserAdmin/Options/UserListOptionsInterface.php b/src/ZfcUserAdmin/Options/UserListOptionsInterface.php index ef24cd9..ea75d67 100644 --- a/src/ZfcUserAdmin/Options/UserListOptionsInterface.php +++ b/src/ZfcUserAdmin/Options/UserListOptionsInterface.php @@ -7,4 +7,8 @@ interface UserListOptionsInterface public function getUserListElements(); public function setUserListElements(array $elements); -} + + public function getUserCountPerPage(); + + public function setUserCountPerPage($UserCountPerPage); +} \ No newline at end of file