Skip to content

Commit

Permalink
Merge pull request #1373 from dereuromark/2.4-paginator
Browse files Browse the repository at this point in the history
Add convenience method param() for PaginatorHelper.
  • Loading branch information
Mark committed Jun 23, 2013
2 parents fb111d6 + d6c25bd commit df1e747
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
26 changes: 25 additions & 1 deletion lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
Expand Up @@ -2143,7 +2143,31 @@ public function testFirstBoundaries() {
}

/**
* 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
*/
Expand Down
16 changes: 16 additions & 0 deletions lib/Cake/View/Helper/PaginatorHelper.php
Expand Up @@ -133,6 +133,22 @@ public function params($model = null) {
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
*
Expand Down

0 comments on commit df1e747

Please sign in to comment.