Last active
December 20, 2015 04:09
-
-
Save AD7six/6069103 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please enter the commit message for your changes. Lines starting | |
# with '#' will be ignored, and an empty message aborts the commit. | |
# On branch 2.4 | |
# Changes to be committed: | |
# (use "git reset HEAD <file>..." to unstage) | |
# | |
# modified: lib/Cake/Controller/Controller.php | |
# | |
# Untracked files: | |
# (use "git add <file>..." to include in what will be committed) | |
# | |
# app/Controller/PostsController.php | |
# app/Model/Post.php | |
# app/Test/Case/Controller/PostsControllerTest.php | |
# app/Test/Case/Model/PostTest.php | |
# app/Test/Fixture/PostFixture.php | |
# app/View/Posts/ | |
# composer.json | |
diff --git lib/Cake/Controller/Controller.php lib/Cake/Controller/Controller.php | |
index aefc83f..717ce20 100644 | |
--- lib/Cake/Controller/Controller.php | |
+++ lib/Cake/Controller/Controller.php | |
@@ -121,6 +121,31 @@ class Controller extends Object implements CakeEventListener { | |
protected $_responseClass = 'CakeResponse'; | |
/** | |
+ * Holds pagination defaults for controller actions. The keys that can be included | |
+ * in this array are: 'conditions', 'fields', 'order', 'limit', 'page', and 'recursive', | |
+ * similar to the keys in the second parameter of Model::find(). | |
+ * | |
+ * Pagination defaults can also be supplied in a model-by-model basis by using | |
+ * the name of the model as a key for a pagination array: | |
+ * | |
+ * {{{ | |
+ * public $paginate = array( | |
+ * 'Post' => array(...), | |
+ * 'Comment' => array(...) | |
+ * ); | |
+ * }}} | |
+ * | |
+ * @var array | |
+ * @link http://book.cakephp.org/view/1231/Pagination | |
+ */ | |
+ public $paginate = array( | |
+ 'limit' => 20, | |
+ 'page' => 1, | |
+ 'maxLimit' => 100, | |
+ 'paramType' => 'named' | |
+ ); | |
+ | |
+/** | |
* The name of the views subfolder containing views for this controller. | |
* | |
* @var string | |
@@ -398,8 +423,6 @@ class Controller extends Object implements CakeEventListener { | |
return isset($this->request->params['action']) ? $this->request->params['action'] : ''; | |
case 'params': | |
return $this->request; | |
- case 'paginate': | |
- return $this->Components->load('Paginator')->settings; | |
} | |
if (isset($this->{$name})) { | |
@@ -427,8 +450,6 @@ class Controller extends Object implements CakeEventListener { | |
return $this->request->params['action'] = $value; | |
case 'params': | |
return $this->request->params = $value; | |
- case 'paginate': | |
- return $this->Components->load('Paginator')->settings = $value; | |
} | |
return $this->{$name} = $value; | |
} | |
@@ -1068,10 +1089,14 @@ class Controller extends Object implements CakeEventListener { | |
* @param array $whitelist List of allowed options for paging | |
* @return array Model query results | |
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::paginate | |
- * @deprecated Use PaginatorComponent instead | |
*/ | |
public function paginate($object = null, $scope = array(), $whitelist = array()) { | |
- return $this->Components->load('Paginator', $this->paginate)->paginate($object, $scope, $whitelist); | |
+ if (!isset($this->Paginator)) { | |
+ $this->Paginator = $this->Components->load('Paginator', $this->paginate); | |
+ } else { | |
+ $this->Paginator->settings = $this->paginate; | |
+ } | |
+ return $this->Paginator->paginate($object, $scope, $whitelist); | |
} | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment