From: Chuck Hagenbuch Date: Mon, 31 May 2010 02:01:45 +0000 (-0400) Subject: Ever since setting the Cache was moved out of the constructor, accessing it was broke... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=93eb9d60556dc9ea66d47dd059637fd7030bf993;p=horde.git Ever since setting the Cache was moved out of the constructor, accessing it was broken from the Schema objects. Fix that. We need to delegate back up to the Adapter now, which also means adding getter methods for the Cache and Logger. --- diff --git a/framework/Db/lib/Horde/Db/Adapter/Base.php b/framework/Db/lib/Horde/Db/Adapter/Base.php index 3b6f81a6e..8939e023b 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Base.php +++ b/framework/Db/lib/Horde/Db/Adapter/Base.php @@ -118,9 +118,8 @@ abstract class Horde_Db_Adapter_Base implements Horde_Db_Adapter /* Can't set cache/logger in constructor - these objects may use DB * for storage. Add stubs for now - they have to be manually set * later with setCache() and setLogger(). */ - $stub = new Horde_Support_Stub(); - $this->_cache = $stub; - $this->_logger = $stub; + $this->_cache = new Horde_Support_Stub(); + $this->_logger = new Horde_Support_Stub(); // Default to UTF-8 if (!isset($config['charset'])) { @@ -163,7 +162,7 @@ abstract class Horde_Db_Adapter_Base implements Horde_Db_Adapter /*########################################################################## - # Dependency setters + # Dependency setters/getters ##########################################################################*/ /** @@ -179,6 +178,14 @@ abstract class Horde_Db_Adapter_Base implements Horde_Db_Adapter } /** + * @return Horde_Cache_Base + */ + public function getCache() + { + return $this->_cache; + } + + /** * Set a logger object. * * @inject @@ -190,6 +197,14 @@ abstract class Horde_Db_Adapter_Base implements Horde_Db_Adapter $this->_logger = $logger; } + /** + * return Horde_Log_Logger + */ + public function getLogger() + { + return $this->_logger; + } + /*########################################################################## # Object composition diff --git a/framework/Db/lib/Horde/Db/Adapter/Base/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Base/Schema.php index e85c96b49..911014bf5 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Base/Schema.php +++ b/framework/Db/lib/Horde/Db/Adapter/Base/Schema.php @@ -24,16 +24,6 @@ abstract class Horde_Db_Adapter_Base_Schema { /** - * @var Cache object - */ - protected $_cache = null; - - /** - * @var Logger - */ - protected $_logger = null; - - /** * @var Horde_Db_Adapter_Base */ protected $_adapter = null; @@ -56,9 +46,6 @@ abstract class Horde_Db_Adapter_Base_Schema { $this->_adapter = $adapter; $this->_adapterMethods = array_flip(get_class_methods($adapter)); - - $this->_cache = isset($config['cache']) ? $config['cache'] : new Horde_Support_Stub; - $this->_logger = isset($config['logger']) ? $config['logger'] : new Horde_Support_Stub; } @@ -118,6 +105,8 @@ abstract class Horde_Db_Adapter_Base_Schema * * @param string $method * @param array $args + * + * @return mixed */ public function __call($method, $args) { @@ -128,6 +117,21 @@ abstract class Horde_Db_Adapter_Base_Schema throw new BadMethodCallException('Call to undeclared method "'.$method.'"'); } + /** + * Delegate access to $_cache and $_logger to the adapter object. + * + * @param string $key + * + * @return mixed + */ + public function __get($key) + { + if ($key == '_cache' || $key == '_logger') { + $getter = 'get' . ucfirst(substr($key, 1)); + return $this->_adapter->$getter(); + } + } + /*########################################################################## # Quoting