Skip to content

Commit

Permalink
Merge pull request #1125 from dogmatic69/find-all-overload
Browse files Browse the repository at this point in the history
Adding the _findAll method
  • Loading branch information
markstory committed Feb 12, 2013
2 parents 82567ed + e9a385e commit 4879d45
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/Cake/Model/Model.php
Expand Up @@ -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);
}
Expand All @@ -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);
}

Expand Down Expand Up @@ -2749,6 +2745,23 @@ public function buildQuery($type = 'first', $query = array()) {
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().
*
Expand Down

0 comments on commit 4879d45

Please sign in to comment.