Permalink
Browse files

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.
  • Loading branch information...
1 parent 13029cc commit e9a385e790e041f7cfa8099605edcfa464e37225 @dogmatic69 dogmatic69 committed Feb 10, 2013
Showing with 18 additions and 5 deletions.
  1. +18 −5 lib/Cake/Model/Model.php
View
@@ -2695,10 +2695,6 @@ public function find($type = 'first', $query = array()) {
$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 @@ public function buildQuery($type = 'first', $query = array()) {
(array)$query
);
- if ($type !== 'all' && $this->findMethods[$type] === true) {
+ if ($this->findMethods[$type] === true) {
$query = $this->{'_find' . ucfirst($type)}('before', $query);
}
@@ -2750,6 +2746,23 @@ public function buildQuery($type = 'first', $query = array()) {
}
/**
+ * 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().
*
* @param string $state Either "before" or "after"

0 comments on commit e9a385e

Please sign in to comment.