Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pagination adapter for the zend framework 1

  • Loading branch information...
commit 12e346dcebd5ec74754eee3abf082a5b8e3e36b1 1 parent a8f6a47
@kkamkou authored
Showing with 58 additions and 0 deletions.
  1. +58 −0 src/3rdparty/Morph.php
View
58 src/3rdparty/Morph.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * @package Morph
+ * @author Kanstantsin Kamkou <kkamkou@gmail.com>
+ */
+
+/**
+ * @see Zend_Paginator_Adapter_Interface
+ */
+class Yourproject_Paginator_Adapter_Morph implements Zend_Paginator_Adapter_Interface
+{
+ /**
+ * Item count
+ * @var integer
+ */
+ protected $_count = null;
+
+ /**
+ * Stores the morph object
+ * @var \morph\Iterator
+ */
+ protected $_iterator;
+
+ /**
+ * Constructor
+ *
+ * @param \morph\Iterator $iterator
+ */
+ public function __construct(\morph\Iterator $iterator)
+ {
+ $this->_iterator = $iterator;
+ $this->_count = $iterator->totalCount();
+ }
+
+ /**
+ * Returns an collection of items for a page.
+ *
+ * @param integer $offset Page offset
+ * @param integer $itemCountPerPage Number of items per page
+ * @return \morph\Iterator
+ */
+ public function getItems($offset, $itemCountPerPage)
+ {
+ $this->_iterator->getCursor()
+ ->skip($offset)
+ ->limit($itemCountPerPage);
+ return $this->_iterator;
+ }
+
+ /**
+ * Returns count of entries
+ * @return int
+ */
+ public function count()
+ {
+ return $this->_count;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.