Skip to content

Commit

Permalink
Update doc blocks and add an early return.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 21, 2013
1 parent 0856b59 commit 711f29e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
33 changes: 19 additions & 14 deletions Cake/Controller/Component/PaginatorComponent.php
Expand Up @@ -91,24 +91,24 @@ public function __construct(ComponentRegistry $collection, $settings = []) {
* Otherwise the top level configuration will be used.
*
* {{{
* $settings = array(
* $settings = [
* 'limit' => 20,
* 'maxLimit' => 100
* );
* ];
* $results = $paginator->paginate($table, $settings);
* }}}
*
* The above settings will be used to paginate any Table. You can configure Table specific settings by
* keying the settings with the Table alias.
*
* {{{
* $settings = array(
* 'Posts' => array(
* $settings = [
* 'Articles' => [
* 'limit' => 20,
* 'maxLimit' => 100
* ),
* 'Comments' => array( ... )
* );
* [,
* 'Comments' => [ ... ]
* ];
* $results = $paginator->paginate($table, $settings);
* }}}
*
Expand All @@ -119,12 +119,12 @@ public function __construct(ComponentRegistry $collection, $settings = []) {
* You can paginate with any find type defined on your table using the `findType` option.
*
* {{{
* $settings = array(
* 'Post' => array(
* 'findType' => 'popular'
* )
* );
* $results = $paginator->paginate($table, $settings);
* $settings = array(
* 'Articles' => array(
* 'findType' => 'popular'
* )
* );
* $results = $paginator->paginate($table, $settings);
* }}}
*
* Would paginate using the `find('popular')` method.
Expand Down Expand Up @@ -303,7 +303,12 @@ public function validateSort(Table $object, array $options, array $whitelist = a
$options['order'] = array($options['sort'] => $direction);
}

if (!empty($whitelist) && isset($options['order']) && is_array($options['order'])) {
if (empty($options['order']) || (isset($options['order']) && is_array($options['order']))) {
$options['order'] = null;
return $options;
}

if (!empty($whitelist)) {
$field = key($options['order']);
$inWhitelist = in_array($field, $whitelist, true);
if (!$inWhitelist) {
Expand Down
Expand Up @@ -610,7 +610,8 @@ public function testValidateSortNoSort() {
$model->expects($this->any())
->method('alias')
->will($this->returnValue('model'));
$model->expects($this->any())->method('hasField')->will($this->returnValue(true));
$model->expects($this->any())->method('hasField')
->will($this->returnValue(true));

$options = array('direction' => 'asc');
$result = $this->Paginator->validateSort($model, $options, array('title', 'id'));
Expand Down

0 comments on commit 711f29e

Please sign in to comment.