Merge pull request #1373 from dereuromark/2.4-paginator

Add convenience method param() for PaginatorHelper.
This commit is contained in:
Mark 2013-06-23 16:43:55 -07:00
commit df1e74765b
2 changed files with 41 additions and 1 deletions

View file

@ -2143,7 +2143,31 @@ class PaginatorHelperTest extends CakeTestCase {
} }
/** /**
* test Last method * test params() method
*
* @return void
*/
public function testParams() {
$result = $this->Paginator->params();
$this->assertArrayHasKey('page', $result);
$this->assertArrayHasKey('pageCount', $result);
}
/**
* test param() method
*
* @return void
*/
public function testParam() {
$result = $this->Paginator->param('count');
$this->assertIdentical(62, $result);
$result = $this->Paginator->param('imaginary');
$this->assertNull($result);
}
/**
* test last() method
* *
* @return void * @return void
*/ */

View file

@ -133,6 +133,22 @@ class PaginatorHelper extends AppHelper {
return $this->request->params['paging'][$model]; return $this->request->params['paging'][$model];
} }
/**
* Convenience access to any of the paginator params.
*
* @param string $key Key of the paginator params array to retreive.
* @param string $model Optional model name. Uses the default if none is specified.
* @return mixed Content of the requested param.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::params
*/
public function param($key, $model = null) {
$params = $this->params($model);
if (!isset($params[$key])) {
return null;
}
return $params[$key];
}
/** /**
* Sets default options for all pagination links * Sets default options for all pagination links
* *