--- Db/Table/Rowset/Abstract.php (revision 14018) +++ Db/Table/Rowset/Abstract.php (working copy) @@ -116,7 +116,7 @@ if (isset($config['rowClass'])) { $this->_rowClass = $config['rowClass']; } - Zend_Loader::loadClass($this->_rowClass); + Zend_Db_Table_Abstract::loadClass($this->_rowClass); if (isset($config['data'])) { $this->_data = $config['data']; } Index: Db/Table/Row/Abstract.php =================================================================== --- Db/Table/Row/Abstract.php (revision 14018) +++ Db/Table/Row/Abstract.php (working copy) @@ -122,7 +122,7 @@ $this->_table = $config['table']; $this->_tableClass = get_class($this->_table); } else if ($this->_tableClass !== null) { - Zend_Loader::loadClass($this->_tableClass); + Zend_Db_Table_Abstract::loadClass($this->_tableClass); $this->_table = new $this->_tableClass(); } @@ -528,7 +528,7 @@ $pkOld = $this->_getPrimaryKey(false); foreach ($depTables as $tableClass) { try { - Zend_Loader::loadClass($tableClass); + Zend_Db_Table_Abstract::loadClass($tableClass); } catch (Zend_Exception $e) { require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception($e->getMessage()); @@ -606,7 +606,7 @@ $pk = $this->_getPrimaryKey(); foreach ($depTables as $tableClass) { try { - Zend_Loader::loadClass($tableClass); + Zend_Db_Table_Abstract::loadClass($tableClass); } catch (Zend_Exception $e) { require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception($e->getMessage()); @@ -859,7 +859,7 @@ if (is_string($dependentTable)) { try {; - Zend_Loader::loadClass($dependentTable); + Zend_Db_Table_Abstract::loadClass($dependentTable); } catch (Zend_Exception $e) { require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception($e->getMessage()); @@ -912,7 +912,7 @@ if (is_string($parentTable)) { try { - Zend_Loader::loadClass($parentTable); + Zend_Db_Table_Abstract::loadClass($parentTable); } catch (Zend_Exception $e) { require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception($e->getMessage()); @@ -966,7 +966,7 @@ if (is_string($intersectionTable)) { try { - Zend_Loader::loadClass($intersectionTable); + Zend_Db_Table_Abstract::loadClass($intersectionTable); } catch (Zend_Exception $e) { require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception($e->getMessage()); @@ -984,7 +984,7 @@ if (is_string($matchTable)) { try { - Zend_Loader::loadClass($matchTable); + Zend_Db_Table_Abstract::loadClass($matchTable); } catch (Zend_Exception $e) { require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception($e->getMessage()); @@ -1052,7 +1052,7 @@ $rowsetClass = $matchTable->getRowsetClass(); try { - Zend_Loader::loadClass($rowsetClass); + Zend_Db_Table_Abstract::loadClass($rowsetClass); } catch (Zend_Exception $e) { require_once 'Zend/Db/Table/Row/Exception.php'; throw new Zend_Db_Table_Row_Exception($e->getMessage()); Index: Db/Table/Abstract.php =================================================================== --- Db/Table/Abstract.php (revision 14018) +++ Db/Table/Abstract.php (working copy) @@ -81,6 +81,13 @@ * @var Zend_Db_Adapter_Abstract */ protected static $_defaultDb; + + /** + * Default Loader to use for class loading + * + * @var null|array either non loader is used or a vaild callback + */ + protected static $_loader = array('Zend_Loader','loadClass'); /** * Default cache for information provided by the adapter's describeTable() method. @@ -525,6 +532,61 @@ } return $db; } + + /** + * Set the loader that all Zend_Db_Table classes use to load dependent + * classes. + * + * @param null|array $loader null to use autoloader or a vaild callback array + */ + public static function setLoader($loader) + { + self::$_loader = self::_setupLoader($loader); + } + + /** + * Gets the current loader + * + * @return null|array + */ + public static function getLoader() + { + return self::$_loader; + } + + /** + * loads a dependent class, used by all Zend_Db_Table classes + * + * @param string $class + */ + public static function loadClass($class) + { + if (null !== self::getLoader()) { + return call_user_func_array(self::getLoader(), func_get_args()); + } + } + + /** + * Sets up the loader and make sure its valid + * + * @param null|array $loader + * @return null|array + */ + protected static function _setupLoader($loader) + { + if (null === $loader) { + return $loader; + } + if (is_array($loader)) { + if (2 !== count($loader)) { + require_once 'Zend/Db/Table/Exception.php'; + throw new Zend_Db_Table_Exception('Invalid loader callback given'); + } + return $loader; + } + require_once 'Zend/Db/Table/Exception.php'; + throw new Zend_Db_Table_Exception('Invalid loader given, must be either null or a vaild callback array'); + } /** * Sets the default metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable(). @@ -1219,7 +1281,7 @@ 'stored' => true ); - Zend_Loader::loadClass($this->_rowsetClass); + self::loadClass($this->_rowsetClass); return new $this->_rowsetClass($data); } @@ -1264,7 +1326,7 @@ 'stored' => true ); - Zend_Loader::loadClass($this->_rowClass); + self::loadClass($this->_rowClass); return new $this->_rowClass($data); } @@ -1323,7 +1385,7 @@ 'stored' => false ); - Zend_Loader::loadClass($this->_rowClass); + self::loadClass($this->_rowClass); $row = new $this->_rowClass($config); $row->setFromArray($data); return $row;