Adding convertKeys to PaginatorHelper::options().

Added a test case.
Fixes #1390
This commit is contained in:
mark_story 2010-12-26 13:24:05 -05:00
parent 83d12ce690
commit edf567b9f9
2 changed files with 20 additions and 1 deletions

View file

@ -66,7 +66,7 @@ class PaginatorHelper extends AppHelper {
* - `$options['escape']` Defines if the title field for the link should be escaped (default: true). * - `$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. * - `$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. * 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. * '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 * - `convertKeys` - A list of keys in url arrays that should be converted to querysting params
* if paramType == 'querystring'. * if paramType == 'querystring'.
@ -163,6 +163,9 @@ class PaginatorHelper extends AppHelper {
); );
unset($options[$model]); 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)); $this->options = array_filter(array_merge($this->options, $options));
} }

View file

@ -2242,6 +2242,22 @@ class PaginatorHelperTest extends CakeTestCase {
$this->assertTags($result, $expected); $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 * test the current() method
* *