Merge pull request #1592 from kimegede/model-after-find-if-condition-remove

Reduce if condtion for finds
This commit is contained in:
José Lorenzo Rodríguez 2013-09-01 11:24:23 -07:00
commit 64cf40558f

View file

@ -2818,9 +2818,9 @@ class Model extends Object implements CakeEventListener {
protected function _findAll($state, $query, $results = array()) {
if ($state === 'before') {
return $query;
} elseif ($state === 'after') {
return $results;
}
return $results;
}
/**
@ -2836,13 +2836,13 @@ class Model extends Object implements CakeEventListener {
if ($state === 'before') {
$query['limit'] = 1;
return $query;
} elseif ($state === 'after') {
}
if (empty($results[0])) {
return array();
}
return $results[0];
}
}
/**
* Handles the before/after filter logic for find('count') operations. Only called by Model::find().
@ -2877,7 +2877,8 @@ class Model extends Object implements CakeEventListener {
));
}
return $query;
} elseif ($state === 'after') {
}
foreach (array(0, $this->alias) as $key) {
if (isset($results[0][$key]['count'])) {
if ($query['group']) {
@ -2888,7 +2889,6 @@ class Model extends Object implements CakeEventListener {
}
return false;
}
}
/**
* Handles the before/after filter logic for find('list') operations. Only called by Model::find().
@ -2939,13 +2939,13 @@ class Model extends Object implements CakeEventListener {
}
list($query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']) = $list;
return $query;
} elseif ($state === 'after') {
}
if (empty($results)) {
return array();
}
return Hash::combine($results, $query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']);
}
}
/**
* Detects the previous field's value, then uses logic to find the 'wrapping'
@ -2974,7 +2974,8 @@ class Model extends Object implements CakeEventListener {
$query['field'] = $field;
$query['value'] = $value;
return $query;
} elseif ($state === 'after') {
}
extract($query);
unset($query['conditions'][$field . ' <']);
$return = array();
@ -3002,7 +3003,6 @@ class Model extends Object implements CakeEventListener {
}
return $return;
}
}
/**
* In the event of ambiguous results returned (multiple top level results, with different parent_ids)
@ -3016,7 +3016,8 @@ class Model extends Object implements CakeEventListener {
protected function _findThreaded($state, $query, $results = array()) {
if ($state === 'before') {
return $query;
} elseif ($state === 'after') {
}
$parent = 'parent_id';
if (isset($query['parent'])) {
$parent = $query['parent'];
@ -3026,7 +3027,6 @@ class Model extends Object implements CakeEventListener {
'parentPath' => '{n}.' . $this->alias . '.' . $parent
));
}
}
/**
* Passes query results through model and behavior afterFilter() methods.