Skip to content
Permalink
Browse files

Incorporate feedback on pull request.

  • Loading branch information...
markstory committed Jul 2, 2016
1 parent 01ba43c commit 066f15500913e25157c1850d5ea89d670f00fa17
@@ -159,7 +159,7 @@ public function paginate($object, array $settings = [])
$options = $this->validateSort($object, $options);
$options = $this->checkLimit($options);
$options += ['page' => 1];
$options += ['page' => 1, 'prefix' => null];
$options['page'] = (int)$options['page'] < 1 ? 1 : (int)$options['page'];
list($finder, $options) = $this->_extractFinder($options);
@@ -204,7 +204,7 @@ public function paginate($object, array $settings = [])
'limit' => $defaults['limit'] != $limit ? $limit : null,
'sortDefault' => $sortDefault,
'directionDefault' => $directionDefault,
'prefix' => Hash::get($options, 'prefix', null),
'prefix' => $options['prefix'],
];
if (!isset($request['paging'])) {
@@ -419,7 +419,7 @@ public function sort($key, $title = null, array $options = [])
$sortKey = $this->sortKey($options['model']);
$defaultModel = $this->defaultModel();
$model = Hash::get($options, 'model', $defaultModel);
$model = $options['model'] ?: $defaultModel;
list($table, $field) = explode('.', $key . '.');
if (!$field) {
$field = $table;
@@ -144,6 +144,7 @@ public function testPaginateExtraParams()
'order' => ['PaginatorPosts.id' => 'ASC'],
'page' => 1,
'whitelist' => ['limit', 'sort', 'page', 'direction'],
'prefix' => null,
]);
$this->Paginator->paginate($table, $settings);
}
@@ -227,6 +228,7 @@ public function testDefaultPaginateParams()
'page' => 1,
'order' => ['PaginatorPosts.id' => 'DESC'],
'whitelist' => ['limit', 'sort', 'page', 'direction'],
'prefix' => null,
]);
$this->Paginator->paginate($table, $settings);
@@ -258,6 +260,7 @@ public function testDefaultPaginateParamsIntoRequest()
'page' => 1,
'order' => ['PaginatorPosts.id' => 'DESC'],
'whitelist' => ['limit', 'sort', 'page', 'direction'],
'prefix' => null,
]);
$this->Paginator->paginate($table, $settings);
@@ -519,6 +522,7 @@ public function testValidateSortInvalid()
'page' => 1,
'order' => ['PaginatorPosts.id' => 'asc'],
'whitelist' => ['limit', 'sort', 'page', 'direction'],
'prefix' => null,
]);
$this->request->query = [
@@ -1022,7 +1026,13 @@ public function testPaginateCustomFindCount()
->will($this->returnValue($query));
$query->expects($this->once())->method('applyOptions')
->with(['limit' => 2, 'page' => 1, 'order' => [], 'whitelist' => ['limit', 'sort', 'page', 'direction']]);
->with([
'limit' => 2,
'page' => 1,
'order' => [],
'whitelist' => ['limit', 'sort', 'page', 'direction'],
'prefix' => null,
]);
$this->Paginator->paginate($table, $settings);
}
@@ -1055,6 +1065,7 @@ public function testPaginateQuery()
'order' => ['PaginatorPosts.id' => 'ASC'],
'page' => 1,
'whitelist' => ['limit', 'sort', 'page', 'direction'],
'prefix' => null,
]);
$this->Paginator->paginate($query, $settings);
}
@@ -1114,6 +1125,7 @@ public function testPaginateQueryWithLimit()
'order' => ['PaginatorPosts.id' => 'ASC'],
'page' => 1,
'whitelist' => ['limit', 'sort', 'page', 'direction'],
'prefix' => null,
]);
$this->Paginator->paginate($query, $settings);
}

0 comments on commit 066f155

Please sign in to comment.
You can’t perform that action at this time.