]> BookStack Code Mirror - bookstack/blob - app/Providers/PaginationServiceProvider.php
Added translation string for tasklist WYSIWYG action
[bookstack] / app / Providers / PaginationServiceProvider.php
1 <?php
2
3 namespace BookStack\Providers;
4
5 use Illuminate\Pagination\PaginationServiceProvider as IlluminatePaginationServiceProvider;
6 use Illuminate\Pagination\Paginator;
7
8 class PaginationServiceProvider extends IlluminatePaginationServiceProvider
9 {
10     /**
11      * Register the service provider.
12      *
13      * @return void
14      */
15     public function register()
16     {
17         Paginator::viewFactoryResolver(function () {
18             return $this->app['view'];
19         });
20
21         Paginator::currentPathResolver(function () {
22             return url($this->app['request']->path());
23         });
24
25         Paginator::currentPageResolver(function ($pageName = 'page') {
26             $page = $this->app['request']->input($pageName);
27
28             if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
29                 return $page;
30             }
31
32             return 1;
33         });
34     }
35 }