Download the PHP package franmomu/silex-pagerfanta-provider without Composer
On this page you can find all versions of the php package franmomu/silex-pagerfanta-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download franmomu/silex-pagerfanta-provider
More information about franmomu/silex-pagerfanta-provider
Files in franmomu/silex-pagerfanta-provider
Package silex-pagerfanta-provider
Short Description Silex ServiceProvider for Pagerfanta Library
License MIT
Homepage https://github.com/franmomu/silex-pagerfanta-provider
Informations about the package silex-pagerfanta-provider
PagerfantaServiceProvider
Provider to use Pagerfanta with Silex
This Provider is based on WhiteOctoberPagerfantaBundle and includes:
- Twig function to render pagerfantas with views and options.
- Way to use easily views.
Install
You have to add to your composer.json file:
or if you use Symfony2.2 components:
Registering
Parameters
This are the default parameters:
Rendering pagination
The Twig Extension provides this function:
{{ pagerfanta(my_pager, view_name, view_options) }}
The routes are generated automatically for the current route using the variable "page" to propagate the page number. By default, the bundle uses the DefaultView with the default name.
{{ pagerfanta(my_pager) }}
If you want to use a custom template, add another argument
<div class="pagerfanta">
{{ pagerfanta(my_pager, 'my_template') }}
</div>
With Options
{{ pagerfanta(my_pager, 'default', { 'proximity': 2}) }}
See the Pagerfanta documentation for the list of the parameters.
Adding a custom template
You can use the CSS classes provided with DefaultView, but if you want to create a Custom View, you have to implement , then add the View to the Factory:
$app['pagerfanta.view_factory'] = $app->share($app->extend('pagerfanta.view_factory', function($viewFactory, $app) {
$customView = new \Foo\Bar\View\CustomView();
$viewFactory->add(array(
'my_view' => $customView
));
return $viewFactory;
}));
And if you want set as default view:
$app['pagerfanta.view.options'] = array(
'default_view' => 'my_view'
);
Use in controllers
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\ArrayAdapter;
$app->get('/index', function (Request $request) use ($app) {
$results = $app['some.service']->getResults();
$adapter = new ArrayAdapter($results);
$pagerfanta = new Pagerfanta($adapter);
$pagerfanta->setMaxPerPage(10);
$pagerfanta->setCurrentPage($request->query->get('page', 1));
return $app['twig']->render('index.html', array(
'my_pager' => $pagerfanta
));
})
All versions of silex-pagerfanta-provider with dependencies
pagerfanta/pagerfanta Version ~1.0,>=1.0.3
symfony/property-access Version ~2.2