/* 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'])) {
/*##########################################################################
- # Dependency setters
+ # Dependency setters/getters
##########################################################################*/
/**
}
/**
+ * @return Horde_Cache_Base
+ */
+ public function getCache()
+ {
+ return $this->_cache;
+ }
+
+ /**
* Set a logger object.
*
* @inject
$this->_logger = $logger;
}
+ /**
+ * return Horde_Log_Logger
+ */
+ public function getLogger()
+ {
+ return $this->_logger;
+ }
+
/*##########################################################################
# Object composition
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;
{
$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;
}
*
* @param string $method
* @param array $args
+ *
+ * @return mixed
*/
public function __call($method, $args)
{
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