lithium\data\collection\DocumentSet::_populate PHP Method

_populate() protected method

Extract the next item from the result ressource and wraps it into a Document object.
protected _populate ( ) : mixed
return mixed Returns the next `Document` if exists. Returns `null` otherwise
    protected function _populate()
    {
        if ($this->closed() || !$this->_result->valid()) {
            return;
        }
        $data = $this->_result->current();
        $result = $this->_set($data, null, array('exists' => true, 'original' => true));
        $this->_result->next();
        return $result;
    }

Usage Example

 /**
  * Lazy-loads a document from a query using a reference to a database adapter and a query
  * result resource.
  *
  * @param array $data
  * @param mixed $key
  * @return array
  */
 protected function _populate($data = null, $key = null)
 {
     $item = parent::_populate($data, $key);
     $params = compact('data', 'key', 'item');
     return $this->_filter(__METHOD__, $params, function ($self, $params) {
         return $params['item'];
     });
 }