mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding convertKeys to PaginatorHelper::options().
Added a test case. Fixes #1390
This commit is contained in:
parent
83d12ce690
commit
edf567b9f9
2 changed files with 20 additions and 1 deletions
|
@ -66,7 +66,7 @@ class PaginatorHelper extends AppHelper {
|
|||
* - `$options['escape']` Defines if the title field for the link should be escaped (default: true).
|
||||
* - `$options['update']` DOM id of the element updated with the results of the AJAX call.
|
||||
* If this key isn't specified Paginator will use plain HTML links.
|
||||
* - `$options['paramType']` The type of parameters to use when creating links. Valid options are
|
||||
* - `$options['paging']['paramType']` The type of parameters to use when creating links. Valid options are
|
||||
* 'querystring', 'named', and 'route'. See PaginatorComponent::$settings for more information.
|
||||
* - `convertKeys` - A list of keys in url arrays that should be converted to querysting params
|
||||
* if paramType == 'querystring'.
|
||||
|
@ -163,6 +163,9 @@ class PaginatorHelper extends AppHelper {
|
|||
);
|
||||
unset($options[$model]);
|
||||
}
|
||||
if (!empty($options['convertKeys'])) {
|
||||
$options['convertKeys'] = array_merge($this->options['convertKeys'], $options['convertKeys']);
|
||||
}
|
||||
$this->options = array_filter(array_merge($this->options, $options));
|
||||
}
|
||||
|
||||
|
|
|
@ -2242,6 +2242,22 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that additional keys can be flagged as query string args.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testOptionsConvertKeys() {
|
||||
$this->Paginator->options(array(
|
||||
'convertKeys' => array('something'),
|
||||
'Article' => array('paramType' => 'querystring')
|
||||
));
|
||||
$result = $this->Paginator->url(array('page' => '4', 'something' => 'bar'));
|
||||
$expected = '/?page=4&something=bar';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test the current() method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue