初始化
This commit is contained in:
30
src/resetters/ResetPaginator.php
Normal file
30
src/resetters/ResetPaginator.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace think\worker\resetters;
|
||||
|
||||
use think\App;
|
||||
use think\Paginator;
|
||||
use think\worker\contract\ResetterInterface;
|
||||
use think\worker\Sandbox;
|
||||
|
||||
class ResetPaginator implements ResetterInterface
|
||||
{
|
||||
|
||||
public function handle(App $app, Sandbox $sandbox)
|
||||
{
|
||||
Paginator::currentPathResolver(function () use ($sandbox) {
|
||||
return $sandbox->getSnapshot()->request->baseUrl();
|
||||
});
|
||||
|
||||
Paginator::currentPageResolver(function ($varPage = 'page') use ($sandbox) {
|
||||
|
||||
$page = $sandbox->getSnapshot()->request->param($varPage);
|
||||
|
||||
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
|
||||
return (int) $page;
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user