Skip to content
Permalink
Browse files

if a table implements a finder - call it first

Don't allow a behavior to override finders defined on the table itself
  • Loading branch information...
AD7six committed Nov 8, 2013
1 parent 217b8c0 commit 0a36451b96859e05295ec7b11b5e4a6633dc3783
Showing with 8 additions and 8 deletions.
  1. +8 −8 Cake/ORM/Table.php
@@ -1022,17 +1022,17 @@ protected function _processDelete($entity, $options) {
*/
public function callFinder($type, Query $query, $options = []) {
$finder = 'find' . ucfirst($type);
$behaviorFinder = ($this->_behaviors && $this->_behaviors->hasFinder($finder));
$missingMethod = (!method_exists($this, $finder) && !$behaviorFinder);
if ($missingMethod) {
throw new \BadMethodCallException(
__d('cake_dev', 'Unknown finder method "%s"', $finder)
);
if (method_exists($this, $finder)) {
return $this->{$finder}($query, $options);
}
if ($behaviorFinder) {
if ($this->_behaviors && $this->_behaviors->hasFinder($finder)) {
return $this->_behaviors->call($finder, [$query, $options]);
}
return $this->{$finder}($query, $options);
throw new \BadMethodCallException(
__d('cake_dev', 'Unknown finder method "%s"', $finder)
);
}
/**

0 comments on commit 0a36451

Please sign in to comment.
You can’t perform that action at this time.