1
0
mirror of synced 2025-02-20 22:23:14 +03:00

fixed fatal method delegation bug

This commit is contained in:
zYne 2007-10-07 23:36:28 +00:00
parent d78f992eb6
commit 7391081d81
2 changed files with 15 additions and 5 deletions

View File

@ -1597,16 +1597,14 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
public function __call($method, $args)
{
static $methods = array();
if ( isset( $methods[$method])) {
$template = $methods[$method];
if (($template = $this->_table->getMethodOwner($method)) !== false) {
$template->setInvoker($this);
return call_user_func_array( array($template, $method ), $args);
return call_user_func_array(array($template, $method), $args);
}
foreach ($this->_table->getTemplates() as $template) {
if (method_exists($template, $method)) {
$template->setInvoker($this);
$methods[$method] = $template;
$this->_table->setMethodOwner($method, $template);
return call_user_func_array(array($template, $method), $args);
}

View File

@ -162,6 +162,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* @var array $_filters an array containing all record filters attached to this table
*/
protected $_filters = array();
protected $_invokedMethods = array();
@ -295,6 +297,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$this->_filters[] = new Doctrine_Record_Filter_Standard();
$this->_repository = new Doctrine_Table_Repository($this);
}
public function getMethodOwner($method)
{
return (isset($this->_invokedMethods[$method])) ?
$this->_invokedMethods[$method] : false;
}
public function setMethodOwner($method, $class)
{
$this->_invokedMethods[$method] = $class;
}
/**
* getTemplates
* returns all templates attached to this table