Zend_Paginator Without Adapter Data

If you simply want to take advantage of Zend_Paginators page generation function without feeding it actual data, how do you do it? Simple, implement Zend_Paginator_Adapter_Interface in your custom class and override three functions like below:

<?php
class Dotmanila_Paginator_Adapter_Null implements Zend_Paginator_Adapter_Interface
{
    private $_count = 0;
    
    public function __construct(array $data)
    {
        if(isset($data['count']) AND $data['count'] > 0) {
            $this->_count = $data['count'];
        }
    }

    public function getItems($offset, $itemCountPerPage)
    {
        return array();
    }

    public function count()
    {
        return $this->_count;
    }
}
?>

Then you can use it as you would the paginator class – the only parameter to the constructor is the total number of items to base the paging against.

$dpa = new Dotmanila_Paginator_Adapter_Null(array('count' => $count));
$pages = $dpa->getPages();