From e9a385e790e041f7cfa8099605edcfa464e37225 Mon Sep 17 00:00:00 2001 From: dogmatic69 Date: Sun, 10 Feb 2013 11:19:21 +0000 Subject: [PATCH] Adding the _findAll method Now there are no special checks for find('all') and the find can be overloaded like you would with any other find(*) methods. --- lib/Cake/Model/Model.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index afb547baf..a8c55fdf8 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2695,10 +2695,6 @@ class Model extends Object implements CakeEventListener { $this->findQueryType = null; - if ($type === 'all') { - return $results; - } - if ($this->findMethods[$type] === true) { return $this->{'_find' . ucfirst($type)}('after', $query, $results); } @@ -2721,7 +2717,7 @@ class Model extends Object implements CakeEventListener { (array)$query ); - if ($type !== 'all' && $this->findMethods[$type] === true) { + if ($this->findMethods[$type] === true) { $query = $this->{'_find' . ucfirst($type)}('before', $query); } @@ -2749,6 +2745,23 @@ class Model extends Object implements CakeEventListener { return $query; } +/** + * Handles the before/after filter logic for find('all') operations. Only called by Model::find(). + * + * @param string $state Either "before" or "after" + * @param array $query + * @param array $results + * @return array + * @see Model::find() + */ + protected function _findAll($state, $query, $results = array()) { + if ($state === 'before') { + return $query; + } elseif ($state === 'after') { + return $results; + } + } + /** * Handles the before/after filter logic for find('first') operations. Only called by Model::find(). *