mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
Merge pull request #1373 from dereuromark/2.4-paginator
Add convenience method param() for PaginatorHelper.
This commit is contained in:
commit
df1e74765b
2 changed files with 41 additions and 1 deletions
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue