PaginationState.php
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Illuminate\Pagination;
class PaginationState
{
/**
* Bind the pagination state resolvers using the given application container as a base.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public static function resolveUsing($app)
{
Paginator::viewFactoryResolver(function () use ($app) {
return $app['view'];
});
Paginator::currentPathResolver(function () use ($app) {
return $app['request']->url();
});
Paginator::currentPageResolver(function ($pageName = 'page') use ($app) {
$page = $app['request']->input($pageName);
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
return (int) $page;
}
return 1;
});
Paginator::queryStringResolver(function () use ($app) {
return $app['request']->query();
});
CursorPaginator::currentCursorResolver(function ($cursorName = 'cursor') use ($app) {
return Cursor::fromEncoded($app['request']->input($cursorName));
});
}
}