Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Paginator Class Reference

Public Member Functions

 __construct ($adapter)
 Constructor.
 
 __toString ()
 Serializes the object as a string.
 
 setCacheEnabled ($enable)
 Enables/Disables the cache for this instance.
 
 count ()
 Returns the number of pages.
 
 getTotalItemCount ()
 Returns the total number of items available.
 
 clearPageItemCache ($pageNumber=null)
 Clear the page item cache.
 
 getAbsoluteItemNumber ($relativeItemNumber, $pageNumber=null)
 Returns the absolute item number for the specified item.
 
 getAdapter ()
 Returns the adapter.
 
 getCurrentItemCount ()
 Returns the number of items for the current page.
 
 getCurrentItems ()
 Returns the items for the current page.
 
 getCurrentPageNumber ()
 Returns the current page number.
 
 setCurrentPageNumber ($pageNumber)
 Sets the current page number.
 
 getFilter ()
 Get the filter.
 
 setFilter (FilterInterface $filter)
 Set a filter chain.
 
 getItem ($itemNumber, $pageNumber=null)
 Returns an item from a page.
 
 getItemCountPerPage ()
 Returns the number of items per page.
 
 setItemCountPerPage ($itemCountPerPage=-1)
 Sets the number of items per page.
 
 getItemCount ($items)
 Returns the number of items in a collection.
 
 getItemsByPage ($pageNumber)
 Returns the items for a given page.
 
 getIterator ()
 Returns a foreach-compatible iterator.
 
 getPageRange ()
 Returns the page range (see property declaration above).
 
 setPageRange ($pageRange)
 Sets the page range (see property declaration above).
 
 getPages ($scrollingStyle=null)
 Returns the page collection.
 
 getPagesInRange ($lowerBound, $upperBound)
 Returns a subset of pages within a given range.
 
 getPageItemCache ()
 Returns the page item cache.
 
 getView ()
 Retrieves the view instance.
 
 setView (View\Renderer\RendererInterface $view=null)
 Sets the view object.
 
 normalizeItemNumber ($itemNumber)
 Brings the item number in range of the page.
 
 normalizePageNumber ($pageNumber)
 Brings the page number in range of the paginator.
 
 render (View\Renderer\RendererInterface $view=null)
 Renders the paginator.
 
 toJson ()
 Returns the items of the current page as JSON.
 

Static Public Member Functions

static setGlobalConfig ($config)
 Set a global config.
 
static getDefaultScrollingStyle ()
 Returns the default scrolling style.
 
static getDefaultItemCountPerPage ()
 Get the default item count per page.
 
static setDefaultItemCountPerPage ($count)
 Set the default item count per page.
 
static setCache (CacheStorage $cache)
 Sets a cache object.
 
static setDefaultScrollingStyle ($scrollingStyle= 'Sliding')
 Sets the default scrolling style.
 
static setScrollingStylePluginManager ($scrollingAdapters)
 
static getScrollingStylePluginManager ()
 Returns the scrolling style manager.
 

Public Attributes

const CACHE_TAG_PREFIX = 'Zend_Paginator_'
 The cache tag prefix used to namespace Paginator results in the cache.
 

Protected Member Functions

 cacheEnabled ()
 Tells if there is an active cache object and if the cache has not been disabled.
 
 _getCacheId ($page=null)
 Makes an Id for the cache Depends on the adapter object and the page number.
 
 _getCacheInternalId ()
 Get the internal cache id Depends on the adapter and the item count per page.
 
 _calculatePageCount ()
 Calculates the page count.
 
 _createPages ($scrollingStyle=null)
 Creates the page collection.
 
 _loadScrollingStyle ($scrollingStyle=null)
 Loads a scrolling style.
 

Protected Attributes

 $cacheEnabled = true
 
 $adapter = null
 
 $currentItemCount = null
 
 $currentItems = null
 
 $currentPageNumber = 1
 
 $filter = null
 
 $itemCountPerPage = null
 
 $pageCount = null
 
 $pageRange = 10
 
 $pages = null
 
 $view = null
 

Static Protected Attributes

static $adapters = null
 
static $config = null
 
static $defaultScrollingStyle = 'Sliding'
 
static $defaultItemCountPerPage = 10
 
static $scrollingStyles = null
 
static $cache
 

Constructor & Destructor Documentation

__construct (   $adapter)

Constructor.

Parameters
AdapterInterface | AdapterAggregateInterface$adapter
Exceptions
Exception\InvalidArgumentException

Member Function Documentation

__toString ( )

Serializes the object as a string.

Proxies to render().

Returns
string
_calculatePageCount ( )
protected

Calculates the page count.

Returns
int
_createPages (   $scrollingStyle = null)
protected

Creates the page collection.

Parameters
string$scrollingStyleScrolling style
Returns
_getCacheId (   $page = null)
protected

Makes an Id for the cache Depends on the adapter object and the page number.

Used to store item in cache from that Paginator instance and that current page

Parameters
int$page
Returns
string
_getCacheInternalId ( )
protected

Get the internal cache id Depends on the adapter and the item count per page.

Used to tag that unique Paginator instance in cache

Returns
string
_loadScrollingStyle (   $scrollingStyle = null)
protected

Loads a scrolling style.

Parameters
string$scrollingStyle
Returns
ScrollingStyleInterface
Exceptions
Exception\InvalidArgumentException
cacheEnabled ( )
protected

Tells if there is an active cache object and if the cache has not been disabled.

Returns
bool
clearPageItemCache (   $pageNumber = null)

Clear the page item cache.

Parameters
int$pageNumber
Returns
Paginator
count ( )

Returns the number of pages.

Returns
int
getAbsoluteItemNumber (   $relativeItemNumber,
  $pageNumber = null 
)

Returns the absolute item number for the specified item.

Parameters
int$relativeItemNumberRelative item number
int$pageNumberPage number
Returns
int
getAdapter ( )

Returns the adapter.

Returns
AdapterInterface
getCurrentItemCount ( )

Returns the number of items for the current page.

Returns
int
getCurrentItems ( )

Returns the items for the current page.

Returns
Traversable
getCurrentPageNumber ( )

Returns the current page number.

Returns
int
static getDefaultItemCountPerPage ( )
static

Get the default item count per page.

Returns
int
static getDefaultScrollingStyle ( )
static

Returns the default scrolling style.

Returns
string
getFilter ( )

Get the filter.

Returns
FilterInterface
getItem (   $itemNumber,
  $pageNumber = null 
)

Returns an item from a page.

The current page is used if there's no page specified.

Parameters
int$itemNumberItem number (1 to itemCountPerPage)
int$pageNumber
Exceptions
Exception\InvalidArgumentException
Returns
mixed
getItemCount (   $items)

Returns the number of items in a collection.

Parameters
mixed$itemsItems
Returns
int
getItemCountPerPage ( )

Returns the number of items per page.

Returns
int
getItemsByPage (   $pageNumber)

Returns the items for a given page.

Parameters
int$pageNumber
Returns
mixed
getIterator ( )

Returns a foreach-compatible iterator.

Exceptions
Exception\RuntimeException
Returns
Traversable
getPageItemCache ( )

Returns the page item cache.

Returns
array
getPageRange ( )

Returns the page range (see property declaration above).

Returns
int
getPages (   $scrollingStyle = null)

Returns the page collection.

Parameters
string$scrollingStyleScrolling style
Returns
getPagesInRange (   $lowerBound,
  $upperBound 
)

Returns a subset of pages within a given range.

Parameters
int$lowerBoundLower bound of the range
int$upperBoundUpper bound of the range
Returns
array
static getScrollingStylePluginManager ( )
static

Returns the scrolling style manager.

If it doesn't exist it's created.

Returns
ScrollingStylePluginManager
getTotalItemCount ( )

Returns the total number of items available.

Returns
int
getView ( )

Retrieves the view instance.

If none registered, instantiates a PhpRenderer instance.

Returns
|null
normalizeItemNumber (   $itemNumber)

Brings the item number in range of the page.

Parameters
int$itemNumber
Returns
int
normalizePageNumber (   $pageNumber)

Brings the page number in range of the paginator.

Parameters
int$pageNumber
Returns
int
render ( View\Renderer\RendererInterface  $view = null)

Renders the paginator.

Parameters
\Zend\View\Renderer\RendererInterface$view
Returns
string
static setCache ( CacheStorage  $cache)
static

Sets a cache object.

Parameters
CacheStorage$cache
setCacheEnabled (   $enable)

Enables/Disables the cache for this instance.

Parameters
bool$enable
Returns
Paginator
setCurrentPageNumber (   $pageNumber)

Sets the current page number.

Parameters
int$pageNumberPage number
Returns
Paginator $this
static setDefaultItemCountPerPage (   $count)
static

Set the default item count per page.

Parameters
int$count
static setDefaultScrollingStyle (   $scrollingStyle = 'Sliding')
static

Sets the default scrolling style.

Parameters
string$scrollingStyle
setFilter ( FilterInterface  $filter)

Set a filter chain.

Parameters
FilterInterface$filter
Returns
Paginator
static setGlobalConfig (   $config)
static

Set a global config.

Parameters
array | Traversable$config
Exceptions
Exception\InvalidArgumentException
setItemCountPerPage (   $itemCountPerPage = -1)

Sets the number of items per page.

Parameters
int$itemCountPerPage
Returns
Paginator $this
setPageRange (   $pageRange)

Sets the page range (see property declaration above).

Parameters
int$pageRange
Returns
Paginator $this
static setScrollingStylePluginManager (   $scrollingAdapters)
static
setView ( View\Renderer\RendererInterface  $view = null)

Sets the view object.

Parameters
\Zend\View\Renderer\RendererInterface$view
Returns
Paginator
toJson ( )

Returns the items of the current page as JSON.

Returns
string

Member Data Documentation

$adapter = null
protected
$adapters = null
staticprotected
$cache
staticprotected
$cacheEnabled = true
protected
$config = null
staticprotected
$currentItemCount = null
protected
$currentItems = null
protected
$currentPageNumber = 1
protected
$defaultItemCountPerPage = 10
staticprotected
$defaultScrollingStyle = 'Sliding'
staticprotected
$filter = null
protected
$itemCountPerPage = null
protected
$pageCount = null
protected
$pageRange = 10
protected
$pages = null
protected
$scrollingStyles = null
staticprotected
$view = null
protected
const CACHE_TAG_PREFIX = 'Zend_Paginator_'

The cache tag prefix used to namespace Paginator results in the cache.