Download the PHP package iesde/pagerfanta without Composer
On this page you can find all versions of the php package iesde/pagerfanta. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iesde/pagerfanta
More information about iesde/pagerfanta
Files in iesde/pagerfanta
Informations about the package pagerfanta
This project is looking for maintainers - details here.
Pagerfanta
This project is for PHP 7. If you need support for PHP < 7, use Release v1.1.0.
Usage
Some of the other methods available:
Changing the page based on user selection
If you're using the example route-generator function shown below,
the page selected by the user will be available in the page
GET (querystring) parameter.
You would then need to call setCurrentPage
with the value of that parameter:
setMaxPerPage and setCurrentPage
The ->setMaxPerPage()
and ->setCurrentPage()
methods implement
a fluent interface:
The ->setMaxPerPage()
method throws an exception if the max per page
is not valid:
Pagerfanta\Exception\NotIntegerMaxPerPageException
Pagerfanta\Exception\LessThan1MaxPerPageException
Both extend from Pagerfanta\Exception\NotValidMaxPerPageException
.
The ->setCurrentPage()
method throws an exception if the page is not valid:
Pagerfanta\Exception\NotIntegerCurrentPageException
Pagerfanta\Exception\LessThan1CurrentPageException
Pagerfanta\Exception\OutOfRangeCurrentPageException
All of them extend from Pagerfanta\Exception\NotValidCurrentPageException
.
->setCurrentPage()
throws an out ot range exception depending on the
max per page, so if you are going to modify the max per page, you should do it
before setting the current page.
(If you want to use Pagerfanta in a Symfony project, see https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle.)
Adapters
The adapter's concept is very simple. An adapter just returns the number of results and an slice for a offset and length. This way you can adapt a pagerfanta to paginate any kind results simply by creating an adapter.
An adapter must implement the Pagerfanta\Adapter\AdapterInterface
interface, which has these two methods:
Pagerfanta comes with these adapters:
ArrayAdapter
To paginate an array.
MongoAdapter
To paginate Mongo Cursors.
MandangoAdapter
To paginate Mandango Queries.
DoctrineDbalAdapter
To paginate DoctrineDbal query builders.
DoctrineDbalSingleTableAdapter
To simplify the pagination of single table DoctrineDbal query builders.
This adapter only paginates single table query builders, without joins.
DoctrineORMAdapter
To paginate DoctrineORM query objects.
DoctrineODMMongoDBAdapter
To paginate DoctrineODMMongoDB query builders.
DoctrineODMPhpcrAdapter
To paginate Doctrine PHPCR-ODM query builders.
DoctrineCollectionAdapter
To paginate a Doctrine\Common\Collection\Collections
interface
you can use the DoctrineCollectionAdapter
. It proxies to the
count() and slice() methods on the Collections interface for
pagination. This makes sense if you are using Doctrine ORMs Extra
Lazy association features:
DoctrineSelectableAdapter
To paginate a Doctrine\Common\Collection\Selectable
interface
you can use the DoctrineSelectableAdapter
. It uses the matching()
method on the Selectable interface for pagination. This is
especially usefull when using the Doctrine Criteria object to
filter a PersistentCollection:
Note that you should never use this adapter with a PersistentCollection which is not set to use the EXTRA_LAZY fetch mode.
Be careful when using the count()
method, currently Doctrine2
needs to fetch all the records to count the number of elements.
ElasticaAdapter
To paginate an Elastica Query query:
Be careful when paginating a huge set of documents. By default, offset + limit
can't exceed 10000. You can mitigate this by setting the $maxResults
parameter when constructing the ElasticaAdapter
. For more information, see:
#213.
PropelAdapter
To paginate a propel 1 query:
Propel2Adapter
To paginate a propel 2 query:
SolariumAdapter
To paginate a solarium query:
FixedAdapter
Best used when you need to do a custom paging solution and don't want to implement a full adapter for a one-off use case.
It returns always the same data no matter what page you query:
ConcatenationAdapter
Concatenates the results of other adapter instances into a single adapter. It keeps the order of sub adapters and the order of their results.
Views
Views are to render pagerfantas, this way you can reuse your pagerfantas' HTML in several projects, share them and use another ones from another developer's.
The views implement the Pagerfanta\View\ViewInterface
interface,
which has two methods:
RouteGenerator example:
Pagerfanta comes with five views: The default one, three for Twitter Bootstrap, one for Semantic UI and a special optionable view.
DefaultView
This is the default view.
Options (default):
- proximity (3)
- prev_message (Previous)
- next_message (Next)
- css_disabled_class (disabled)
- css_dots_class (dots)
- css_current_class (current)
- dots_text (...)
- container_template ()
- page_template (%text%)
- span_template (%text%)
CSS:
TwitterBootstrapView, TwitterBootstrap3View and TwitterBootstrap4View
These views generate paginators designed for use with Twitter Bootstrap.
TwitterBootstrapView
is for Bootstrap 2; TwitterBootstrap3View
is for Bootstrap 3; TwitterBootstrap4View
is for Bootstrap 4 (alpha).
Options (default):
- proximity (3)
- prev_message (← Previous)
- prev_disabled_href ()
- next_message (Next →)
- next_disabled_href ()
- dots_message (…)
- dots_href ()
- css_container_class (pagination)
- css_prev_class (prev)
- css_next_class (next)
- css_disabled_class (disabled)
- css_dots_class (disabled)
- css_active_class (active)
SemanticUiView
This view generates a pagination for Semantic UI.
Options (default):
- proximity (3)
- prev_message (← Previous)
- prev_disabled_href ()
- next_message (Next →)
- next_disabled_href ()
- dots_message (…)
- dots_href ()
- css_container_class (pagination)
- css_item_class (item)
- css_prev_class (prev)
- css_next_class (next)
- css_disabled_class (disabled)
- css_dots_class (disabled)
- css_active_class (active)
OptionableView
This view is to reuse options in different views.
Contributing
We welcome contributions to this project, including pull requests and issues (and discussions on existing issues).
If you'd like to contribute code but aren't sure what, the issues list is a good place to start. If you're a first-time code contributor, you may find Github's guide to forking projects helpful.
All contributors (whether contributing code, involved in issue discussions, or involved in any other way) must abide by our code of conduct.
Acknowledgements
Pagerfanta is inspired by Zend Paginator.
Thanks also to Pablo Díez ([email protected]) for most of the work on the first versions of Pagerfanta.
Licence
Pagerfanta is licensed under the MIT License.