/** * Overrides Controller::paginate() to set paging options in the * Model::paginate property so they available in the Model::paginateCount() * method. This is necessary due to the nature of having to paginate over a * web service result set rather than a database result set. * * @param mixed $object * @param mixed $scope * @param mixed $whitelist * @return array The result set */ public function paginate($object = null, $scope = array(), $whitelist = array()) { // Manually put page, show & sort & direction params from URL if present in // Controller::paginate if (isset($this->passedArgs['page'])) { $this->paginate['page'] = $this->passedArgs['page']; } if (isset($this->passedArgs['show'])) { $this->paginate['limit'] = $this->passedArgs['show']; } if (isset($this->passedArgs['sort'])) { $this->paginate['order'] = $this->passedArgs['sort']; if (isset($this->passedArgs['direction'])) { $this->paginate['order'] .= ' ' . $this->passedArgs['direction']; } } // Merges the Controller::paginate paging params with the // Controller::paginate[Model] paging params if present $options = $this->paginate; if (isset($options[$object])) { $options = array_merge($options, $options[$object]); unset($options[$object]); } // Set the merged paging options in the Model::paginate property, so they // are available in Model::paginateCount() & Model::paginate() methods which // handle pagination of a result set from the web service $this->{$object}->paginate = $this->paginate[$object] = $options; return parent::paginate($object, $scope, $whitelist); }
/** * Overrides Controller::paginate() to set paging options in the * Model::paginate property so they available in the Model::paginateCount() * method. * * @param mixed $object * @param mixed $scope * @param mixed $whitelist * @return array The result set */ public function paginate($object = null, $scope = array(), $whitelist = array()) { if (isset($this->passedArgs['page'])) { $this->paginate['page'] = $this->passedArgs['page']; } if (isset($this->passedArgs['show'])) { $this->paginate['limit'] = $this->passedArgs['show']; } $options = $this->paginate; if (isset($options[$object])) { $options = array_merge($options, $options[$object]); unset($options[$object]); } $this->{$object}->paginate = $this->paginate[$object] = $options; return parent::paginate($object = null, $scope = array(), $whitelist = array()); }