Skip to content

Commit 910a7d2

Browse files
author
Ethan
committed
jsonSerializer
1 parent 380a974 commit 910a7d2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Pagination.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class Pagination implements \JsonSerializable
3737
protected $disabledCssClass = 'disabled';
3838
protected $disabledTag = 'span';
3939

40+
/**
41+
* @var \Closure
42+
*/
43+
public static $jsonSerializer = null;
44+
4045
/**
4146
* 生成页码超链接
4247
*
@@ -212,12 +217,18 @@ protected function appendSuffix($url)
212217
return $url;
213218
}
214219

220+
215221
/**
216222
* 实现JsonSerializable接口,方便转为json时自定义数据。
217223
* @return array
218224
*/
219225
public function jsonSerialize()
220226
{
227+
if (static::$jsonSerializer) {
228+
$cb = static::$jsonSerializer;
229+
return $cb($this);
230+
}
231+
221232
return array(
222233
'itemCount' => intval($this->itemCount),//总记录数
223234
'currentPage' => intval($this->currentPage),//当前页码

0 commit comments

Comments
 (0)