Implementing `Serializable` requires now `__serialize` and `__unserialize`

This commit is contained in:
Johannes Meyer 2022-01-18 16:36:25 +01:00
parent c038e84fc2
commit dd3ceaa637
1 changed files with 16 additions and 0 deletions

View File

@ -70,6 +70,16 @@ class Zend_Paginator_SerializableLimitIterator extends LimitIterator implements
)); ));
} }
public function __serialize(): array
{
return array(
'it' => $this->getInnerIterator(),
'offset' => $this->_offset,
'count' => $this->_count,
'pos' => $this->getPosition(),
);
}
/** /**
* @param string $data representation of the instance * @param string $data representation of the instance
*/ */
@ -80,6 +90,12 @@ class Zend_Paginator_SerializableLimitIterator extends LimitIterator implements
$this->seek($dataArr['pos']+$dataArr['offset']); $this->seek($dataArr['pos']+$dataArr['offset']);
} }
public function __unserialize(array $data): void
{
$this->__construct($data['it'], $data['offset'], $data['count']);
$this->seek($data['pos']+$data['offset']);
}
/** /**
* Returns value of the Iterator * Returns value of the Iterator
* *