/** * Return the Agora_Driver:: instance. * * @param string $scope Instance scope * @param int $forum_id Forum to link to * * @return Agora_Driver The singleton instance. * @throws Agora_Exception */ public function create($scope = 'agora', $forum_id = 0) { if (!isset($this->_instances[$scope])) { $driver = $GLOBALS['conf']['threads']['split'] ? 'SplitSql' : 'Sql'; $params = Horde::getDriverConfig('sql'); $class = 'Agora_Driver_' . $driver; if (!class_exists($class)) { throw new Agora_Exception(sprintf('Unable to load the definition of %s.', $class)); } $params = array('db' => $this->_injector->getInstance('Horde_Db_Adapter'), 'charset' => $params['charset']); $driver = new $class($scope, $params); $this->_instances[$scope] = $driver; } if ($forum_id) { /* Check if there was a valid forum object to get. */ try { $forum = $this->_instances[$scope]->getForum($forum_id); } catch (Horde_Exception $e) { throw new Agora_Exception($e->getMessage()); } /* Set current forum id and forum data */ $this->_instances[$scope]->_forum = $forum; $this->_instances[$scope]->_forum_id = (int) $forum_id; } return $this->_instances[$scope]; }
/** * Return a Nag_Tasklists instance. * * @return Nag_Tasklists */ public function create() { if (!isset($GLOBALS['conf']['tasklists']['driver'])) { $driver = 'Default'; } else { $driver = Horde_String::ucfirst($GLOBALS['conf']['tasklists']['driver']); } if (empty($this->_instances[$driver])) { $class = 'Nag_Tasklists_' . $driver; if (class_exists($class)) { $params = array(); if (!empty($GLOBALS['conf']['share']['auto_create'])) { $params['auto_create'] = true; } switch ($driver) { case 'Default': $params['identity'] = $this->_injector->getInstance('Horde_Core_Factory_Identity')->create(); break; } $this->_instances[$driver] = new $class($GLOBALS['nag_shares'], $GLOBALS['registry']->getAuth(), $params); } else { throw new Nag_Exception(sprintf('Unable to load the definition of %s.', $class)); } } return $this->_instances[$driver]; }
/** * Factory method * * @param string $driver The driver type, leave empty for client connection * @param array $params The driver parameters, leave empty to use default. * * @return mixed The Horde_Imsp object or Horde_Imsp_Client object. * @throws Horde_Exception */ protected function _factory($driver = null, array $params = array()) { $driver = basename($driver); // Use global config if none passed in. if (empty($params)) { $params = $GLOBALS['conf']['imsp']; } elseif (empty($params['auth_method'])) { $params['auth_method'] = $GLOBALS['conf']['imsp']['auth_method']; } $params['authObj'] = $this->_injector->getInstance('Horde_Core_Factory_ImspAuth')->create($params['auth_method'], $params); // @TODO: Separate class for the imtest client? unset($params['auth_method']); try { $socket = new Horde_Imsp_Client_Socket($params); } catch (Horde_Imsp_Exception $e) { throw new Horde_Exception($e); } // Return the client itself if no requested driver. if (empty($driver)) { return $socket; } if (!$socket->authenticate($params)) { throw new Horde_Exception_PermissionDenied(); } $class = $this->_getDriverName($driver, 'Horde_Imsp'); return new $class($socket, $params); }
public function create(Horde_Injector $injector) { $driver = Horde_String::ucfirst($GLOBALS['conf']['group']['driver']); $params = Horde::getDriverConfig('group', $driver); if (!empty($GLOBALS['conf']['group']['cache'])) { $params['cache'] = $injector->getInstance('Horde_Cache'); } switch ($driver) { case 'Contactlists': $class = 'Horde_Group_Contactlists'; $params['api'] = $GLOBALS['registry']->contacts; break; case 'Kolab': $class = 'Horde_Group_Kolab'; $params['ldap'] = $injector->getInstance('Horde_Core_Factory_Ldap')->create('horde', 'group'); break; case 'Ldap': $class = 'Horde_Core_Group_Ldap'; $params['ldap'] = $injector->getInstance('Horde_Core_Factory_Ldap')->create('horde', 'group'); break; case 'Sql': $class = 'Horde_Group_Sql'; $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'group'); break; default: $class = $this->_getDriverName($driver, 'Horde_Group'); break; } return new $class($params); }
/** * Return the Mnemo_Driver:: instance. * * @param mixed $name The notepad to open * * @return Mnemo_Driver * @throws Mnemo_Exception */ public function create($name = '') { if (!isset($this->_instances[$name])) { $driver = $GLOBALS['conf']['storage']['driver']; $params = Horde::getDriverConfig('storage', $driver); $class = 'Mnemo_Driver_' . ucfirst(basename($driver)); if (!class_exists($class)) { throw new Mnemo_Exception(sprintf('Unable to load the definition of %s.', $class)); } switch ($class) { case 'Mnemo_Driver_Sql': if ($params['driverconfig'] != 'horde') { $customParams = $params; unset($customParams['driverconfig'], $customParams['table']); $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('mnemo', $customParams); } else { $params['db'] = $this->_injector->getInstance('Horde_Db_Adapter'); } break; case 'Mnemo_Driver_Kolab': $params = array('storage' => $this->_injector->getInstance('Horde_Kolab_Storage')); } $driver = new $class($name, $params); $this->_instances[$name] = $driver; } return $this->_instances[$name]; }
/** * @return Horde_Core_History * @throws Horde_Exception */ public function create(Horde_Injector $injector) { global $conf; // For BC, default to 'Sql' driver. $driver = empty($conf['history']['driver']) ? 'Sql' : $conf['history']['driver']; $history = null; $user = $injector->getInstance('Horde_Registry')->getAuth(); switch (Horde_String::lower($driver)) { case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'history'); if ($nosql instanceof Horde_History_Mongo) { $history = new Horde_History_Mongo($user, array('mongo_db' => $nosql)); } break; case 'sql': try { $history = new Horde_History_Sql($user, $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'history')); } catch (Exception $e) { } break; } if (is_null($history)) { $history = new Horde_History_Null($user); } elseif ($cache = $injector->getInstance('Horde_Cache')) { $history->setCache($cache); $history = new Horde_Core_History($history); } return $history; }
/** * @throws Horde_Exception */ public function create(Horde_Injector $injector) { global $conf, $injector; if (empty($conf['weather']['provider'])) { throw new Horde_Exception(Horde_Core_Translation::t("Weather support not configured.")); } // Parameters for all driver types $params = array('cache' => $injector->getInstance('Horde_Cache'), 'cache_lifetime' => $conf['weather']['params']['lifetime'], 'http_client' => $injector->createInstance('Horde_Core_Factory_HttpClient')->create()); $driver = $conf['weather']['provider']; switch ($driver) { case 'WeatherUnderground': case 'Wwo': case 'Owm': $params['apikey'] = $conf['weather']['params']['key']; if (!empty($conf['weather']['params']['apiversion'])) { $params['apiVersion'] = $conf['weather']['params']['apiversion']; } break; case 'Metar': $params['db'] = $injector->getInstance('Horde_Db_Adapter'); break; } $class = $this->_getDriverName($driver, 'Horde_Service_Weather'); try { return new $class($params); } catch (InvalidArgumentException $e) { throw new Horde_Exception($e); } }
public function create(Horde_Injector $injector) { global $conf, $session; $driver = empty($conf['token']) ? 'null' : $conf['token']['driver']; $params = empty($conf['token']) ? array() : Horde::getDriverConfig('token', $conf['token']['driver']); $params['logger'] = $injector->getInstance('Horde_Log_Logger'); if (!$session->exists('horde', 'token_secret_key')) { $session->set('horde', 'token_secret_key', strval(new Horde_Support_Randomid())); } $params['secret'] = $session->get('horde', 'token_secret_key'); switch (Horde_String::lower($driver)) { case 'none': $driver = 'null'; break; case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'token'); if ($nosql instanceof Horde_Mongo_Client) { $params['mongo_db'] = $nosql; $driver = 'Horde_Token_Mongo'; } break; case 'sql': $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'token'); break; } if (isset($conf['urls']['token_lifetime'])) { $params['token_lifetime'] = $conf['urls']['token_lifetime'] * 60; } $class = $this->_getDriverName($driver, 'Horde_Token'); return new $class($params); }
/** * Return an Kolab_Driver instance. * * @return Kolab_Driver */ public function create(Horde_Injector $injector) { $driver = Horde_String::ucfirst($GLOBALS['conf']['storage']['driver']); $signature = serialize(array($driver, $GLOBALS['conf']['storage']['params']['driverconfig'])); if (empty($this->_instances[$signature])) { switch ($driver) { case 'Sql': try { if ($GLOBALS['conf']['storage']['params']['driverconfig'] == 'horde') { $db = $injector->getInstance('Horde_Db_Adapter'); } else { $db = $injector->getInstance('Horde_Core_Factory_Db')->create('kolab', 'storage'); } } catch (Horde_Exception $e) { throw new Kolab_Exception($e); } $params = array('db' => $db); break; case 'Ldap': try { $params = array('ldap' => $injector->getIntance('Horde_Core_Factory_Ldap')->create('kolab', 'storage')); } catch (Horde_Exception $e) { throw new Kolab_Exception($e); } break; } $class = 'Kolab_Driver_' . $driver; $this->_instances[$signature] = new $class($params); } return $this->_instances[$signature]; }
/** * Return an Ansel_Storage instance scoped for the current Ansel scope. * Scope is determined by the current value of Ansel_Config::scope * * @return Ansel_Storage */ public function create(Horde_Injector $injector) { $scope = $injector->getInstance('Ansel_Config')->get('scope'); if (empty($this->_instances[$scope])) { $this->_instances[$scope] = new Ansel_Storage($injector->getInstance('Horde_Core_Factory_Share')->create($scope)); $this->_instances[$scope]->setStorage($injector->getInstance('Horde_Db_Adapter')); } return $this->_instances[$scope]; }
/** * Returns a Horde_Db instance for the SQL backend. * * @param Horde_Injector $injector An injector object. * * @return Horde_Db_Adapter A correctly configured Horde_Db_Adapter * instance. * @throws Wicked_Exception */ public function getDb(Horde_Injector $injector) { try { if ($GLOBALS['conf']['storage']['params']['driverconfig'] == 'horde') { return $injector->getInstance('Horde_Db_Adapter'); } return $injector->getInstance('Horde_Core_Factory_Db')->create('wicked', 'storage'); } catch (Horde_Exception $e) { throw new Wicked_Exception($e); } }
public function create(Horde_Injector $injector) { global $conf, $registry; // Backend driver and dependencies $params = array('registry' => $registry); $adapter_params = array('factory' => new Horde_Core_ActiveSync_Imap_Factory()); // Force emailsync to off if we don't have a mail API. if (!$registry->hasInterface('mail')) { $conf['activesync']['emailsync'] = false; } $driver_params = array('connector' => new Horde_Core_ActiveSync_Connector($params), 'imap' => !empty($conf['activesync']['emailsync']) ? new Horde_ActiveSync_Imap_Adapter($adapter_params) : null, 'ping' => $conf['activesync']['ping'], 'state' => $injector->getInstance('Horde_ActiveSyncState'), 'auth' => $this->_getAuth(), 'cache' => $injector->getInstance('Horde_Cache')); return new Horde_Core_ActiveSync_Driver($driver_params); }
public function getRequestConfiguration(Horde_Injector $injector) { $request = $injector->getInstance('Horde_Controller_Request'); $registry = $injector->getInstance('Horde_Registry'); $settingsFinder = $injector->getInstance('Horde_Core_Controller_SettingsFinder'); $config = $injector->createInstance('Horde_Core_Controller_RequestConfiguration'); $uri = substr($request->getPath(), strlen($registry->get('webroot', 'horde'))); $uri = trim($uri, '/'); if (strpos($uri, '/') === false) { $app = $uri; } else { list($app, ) = explode('/', $uri, 2); } $config->setApplication($app); // Check for route definitions. $fileroot = $registry->get('fileroot', $app); $routeFile = $fileroot . '/config/routes.php'; if (!file_exists($routeFile)) { $config->setControllerName('Horde_Core_Controller_NotFound'); return $config; } // Push $app onto the registry $registry->pushApp($app); // Application routes are relative only to the application. Let the // mapper know where they start. $this->_mapper->prefix = $registry->get('webroot', $app); // Set the application controller directory $this->_mapper->directory = $registry->get('fileroot', $app) . '/app/controllers'; // Load application routes. $mapper = $this->_mapper; include $routeFile; if (file_exists($fileroot . '/config/routes.local.php')) { include $fileroot . '/config/routes.local.php'; } // Match // @TODO Cache routes $path = $request->getPath(); if (($pos = strpos($path, '?')) !== false) { $path = substr($path, 0, $pos); } $match = $this->_mapper->match($path); if (isset($match['controller'])) { $config->setControllerName(Horde_String::ucfirst($app) . '_' . Horde_String::ucfirst($match['controller']) . '_Controller'); $config->setSettingsExporterName($settingsFinder->getSettingsExporterName($config->getControllerName())); } else { $config->setControllerName('Horde_Core_Controller_NotFound'); } return $config; }
public function create(Horde_Injector $injector) { global $conf; if (!empty($conf['activesync']['enabled'])) { $driver = !empty($conf['activesync']['storage']) ? $conf['activesync']['storage'] : 'sql'; switch (Horde_String::lower($driver)) { case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'activesync'); return new Horde_ActiveSync_State_Mongo(array('connection' => $nosql)); case 'sql': return new Horde_ActiveSync_State_Sql(array('db' => $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'activesync'))); } } throw new Horde_Exception('ActiveSync is disabled.'); }
public function create(Horde_Injector $injector) { if (empty($GLOBALS['conf']['activesync']['logging']['level'])) { $level = Horde_ActiveSync_Wbxml::LOG_PROTOCOL; } else { $level = $GLOBALS['conf']['activesync']['logging']['level']; } $server = new Horde_ActiveSync($injector->getInstance('Horde_ActiveSyncBackend'), new Horde_ActiveSync_Wbxml_Decoder(fopen('php://input', 'r'), $level), new Horde_ActiveSync_Wbxml_Encoder(fopen('php://output', 'w+'), $level), $injector->getInstance('Horde_ActiveSyncState'), $injector->getInstance('Horde_Controller_Request')); $server->setSupportedVersion($GLOBALS['conf']['activesync']['version']); $server->setLogger(new Horde_Core_ActiveSync_Logger_Factory()); if (!empty($GLOBALS['conf']['openssl']['cafile'])) { $server->setRootCertificatePath($GLOBALS['conf']['openssl']['cafile']); } return $server; }
/** * Attempts to return a concrete instance based on $driver. * * @return Horde_Perms The newly created concrete instance. * @throws Horde_Exception */ public function create(Horde_Injector $injector) { global $conf; $driver = empty($conf['perms']['driver']) ? 'null' : $conf['perms']['driver']; $params = isset($conf['perms']) ? Horde::getDriverConfig('perms', $driver) : array(); switch (Horde_String::lower($driver)) { case 'sql': $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'perms'); break; } $params['cache'] = new Horde_Cache(new Horde_Cache_Storage_Stack(array('stack' => array(new Horde_Cache_Storage_Memory(), $injector->getInstance('Horde_Cache'))))); $params['logger'] = $injector->getInstance('Horde_Log_Logger'); $class = $this->_getDriverName($driver, 'Horde_Perms'); return new $class($params); }
/** * Return the Ulaform_Driver:: instance. * * @param mixed $name Instance name * * @return Ulaform_Driver * @throws Ulaform_Exception */ public function create($name = '') { if (!isset($this->_instances[$name])) { $driver = 'Sql'; $params = Horde::getDriverConfig('sql', $driver); $class = 'Ulaform_Driver_' . $driver; if (!class_exists($class)) { throw new Ulaform_Exception(sprintf('Unable to load the definition of %s.', $class)); } $params = array('db' => $this->_injector->getInstance('Horde_Db_Adapter'), 'charset' => $params['charset']); $driver = new $class($params); $this->_instances[$name] = $driver; } return $this->_instances[$name]; }
/** * @throws Horde_Exception */ public function create(Horde_Injector $injector) { if (empty($GLOBALS['conf']['timezone']['location'])) { throw new Horde_Exception('Timezone database location is not configured'); } return new Horde_Timezone(array('cache' => $injector->getInstance('Horde_Cache'), 'location' => $GLOBALS['conf']['timezone']['location'], 'temp' => Horde::getTempDir())); }
public function testMock() { $injector = new Horde_Injector(new Horde_Injector_TopLevel()); $injector->bindFactory('Horde_Group', 'Horde_Core_Factory_Group', 'create'); $GLOBALS['conf']['group']['driver'] = 'mock'; $this->assertInstanceOf('Horde_Group_Mock', $injector->getInstance('Horde_Group')); }
/** * Attempts to return a concrete instance based on $driver. * * @return Horde_SessionHandler_Driver The newly created concrete * instance. * @throws Horde_SessionHandler_Exception */ public function create(Horde_Injector $injector) { global $conf; if (empty($conf['sessionhandler']['type'])) { $driver = 'Builtin'; } else { $driver = $conf['sessionhandler']['type']; if (!strcasecmp($driver, 'None')) { $driver = 'Builtin'; } } $params = Horde::getDriverConfig('sessionhandler', $driver); $driver = basename(Horde_String::lower($driver)); $noset = false; switch ($driver) { case 'builtin': $noset = true; break; case 'hashtable': // DEPRECATED // DEPRECATED case 'memcache': $params['hashtable'] = $injector->getInstance('Horde_HashTable'); $driver = 'hashtable'; break; case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'sessionhandler'); if ($nosql instanceof Horde_Mongo_Client) { $params['mongo_db'] = $nosql; $driver = 'Horde_SessionHandler_Storage_Mongo'; } break; case 'sql': $factory = $injector->getInstance('Horde_Core_Factory_Db'); $config = $factory->getConfig('sessionhandler'); unset($config['umask'], $config['driverconfig']); $params['db'] = $factory->createDb($config); break; } $class = $this->_getDriverName($driver, 'Horde_SessionHandler_Storage'); $storage = $this->storage = new $class($params); if ((!empty($conf['sessionhandler']['hashtable']) || !empty($conf['sessionhandler']['memcache'])) && !in_array($driver, array('builtin', 'hashtable'))) { $storage = new Horde_SessionHandler_Storage_Stack(array('stack' => array(new Horde_SessionHandler_Storage_Hashtable(array('hashtable' => $injector->getInstance('Horde_HashTable'))), $this->storage))); } return new Horde_SessionHandler($storage, array('logger' => $injector->getInstance('Horde_Log_Logger'), 'no_md5' => true, 'noset' => $noset, 'parse' => array($this, 'readSessionData'))); }
public function create(Horde_Injector $injector) { $registry = $injector->getInstance('Horde_Registry'); $view = new Horde_View(array('templatePath' => $registry->get('templates', $registry->getApp()))); $view->addHelper('Tag'); $view->addHelper('Text'); return $view; }
/** * Return an Sam_Driver_Base instance. * * @return Sam_Driver_Base * @throws Sam_Exception */ public function create(Horde_Injector $injector) { $backend = Sam::getPreferredBackend(); $signature = hash('md5', serialize($backend)); if (empty($this->_instances[$signature])) { $user = Sam::mapUser($backend['hordeauth']); switch ($backend['driver']) { case 'Amavisd_Sql': case 'Spamd_Sql': $db_params = array_merge(Horde::getDriverConfig(null, 'sql'), $backend['params']); unset($db_params['table_map']); try { $db = $injector->getInstance('Horde_Core_Factory_Db')->create('sam', $db_params); } catch (Horde_Exception $e) { throw new Sam_Exception($e); } $params = array_merge($backend['params'], array('db' => $db)); break; case 'Spamd_Ldap': $params = array_merge(array('binddn' => sprintf('%s=%s,%s', $backend['params']['uid'], $user, $backend['params']['basedn']), 'bindpw' => $GLOBALS['registry']->getAuthCredential('password')), $backend['params']); try { $ldap = $injector->getInstance('Horde_Core_Factory_Ldap')->create('sam', $params); } catch (Horde_Exception $e) { throw new Sam_Exception($e); } $params = array_merge($backend['params'], array('ldap' => $ldap)); break; case 'Spamd_Ftp': $params = array_merge(array('username' => $user, 'password' => $GLOBALS['registry']->getAuthCredential('password')), $backend['params']); try { $vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create('sam', array('type' => 'ftp', 'params' => $params)); } catch (Horde_Exception $e) { throw new Sam_Exception($e); } $params = array_merge($backend['params'], array('vfs' => $vfs)); break; default: $params = $backend['params']; break; } $class = 'Sam_Driver_' . $backend['driver']; $this->_instances[$signature] = new $class($user, $params); } return $this->_instances[$signature]; }
/** * Return the driver instance. * * @return Kronolith_Storage * @throws Kronolith_Exception */ public function create(Horde_Injector $injector) { if (empty($GLOBALS['conf']['maps']['geodriver'])) { throw new Kronolith_Exception('Geospatial support not configured.'); } $class = 'Kronolith_Geo_' . $GLOBALS['conf']['maps']['geodriver']; $db = $injector->getInstance('Horde_Db_Adapter'); return new $class($db); }
/** * @throws Horde_Exception */ public function create(Horde_Injector $injector) { global $conf; if (empty($conf['facebook']['id']) || empty($conf['facebook']['secret'])) { throw new Horde_Exception('Unable to find required Facebook configuration.'); } $fb = new Horde_Service_Facebook($conf['facebook']['id'], $conf['facebook']['secret'], array('http_client' => $injector->getInstance('Horde_Core_Factory_HttpClient')->create(), 'http_request' => $injector->getInstance('Horde_Controller_Request_Http'))); /* Check for facebook session */ $fbp = unserialize($GLOBALS['prefs']->getValue('facebook')); if (!empty($fbp['sid'])) { try { $fb->auth->setSession($fbp['sid']); } catch (Horde_Service_Facebook_Exception $e) { throw new Horde_Exception($e); } } return $fb; }
/** * Export elements from the injector into global scope. * * @param array $elements The elements to export. * * @return NULL */ public function makeGlobal($elements) { if (!empty($this->_error)) { return; } foreach ($elements as $key => $interface) { $GLOBALS[$key] = $this->_injector->getInstance($interface); } }
/** * Return the mail autoconfig instance. * * @return Horde_Mail_Autoconfig The singleton instance. */ public function create(Horde_Injector $injector) { /* Need to manually set the drivers, since we should be using Horde * objects for Http_Client and Net_DNS2_Resolver. The return from * getDrivers() is already in priority order, so we don't need to * worry about that. */ $drivers = array(); foreach (Horde_Mail_Autoconfig::getDrivers() as $val) { $val = clone $val; if ($val instanceof Horde_Mail_Autoconfig_Driver_Guess || $val instanceof Horde_Mail_Autoconfig_Driver_Srv) { $val->dns = $injector->getInstance('Net_DNS2_Resolver'); } elseif ($val instanceof Horde_Mail_Autoconfig_Driver_Thunderbird) { $val->http = $injector->getInstance('Horde_Http_Client'); } $drivers[] = $val; } return new Horde_Mail_Autoconfig(array('drivers' => $drivers)); }
/** * @param Horde_Injector $injector * @param ReflectionParameter $method * * @return mixed * @throws Horde_Injector_Exception */ public function getParameterDependency(Horde_Injector $injector, ReflectionParameter $parameter) { if ($parameter->getClass()) { return $injector->getInstance($parameter->getClass()->getName()); } elseif ($parameter->isOptional()) { return $parameter->getDefaultValue(); } throw new Horde_Injector_Exception("Untyped parameter \$" . $parameter->getName() . "can't be fulfilled"); }
/** * Return the global Horde_Cache instance. * * @return Horde_Cache Cache object. * @throws Horde_Cache_Exception */ public function create(Horde_Injector $injector) { global $conf; $params = array('compress' => true, 'logger' => $injector->getInstance('Horde_Core_Log_Wrapper')); if (isset($conf['cache']['default_lifetime'])) { $params['lifetime'] = $conf['cache']['default_lifetime']; } $driver = $this->getDriverName(); $sparams = Horde::getDriverConfig('cache', $driver); switch ($driver) { case 'hashtable': // DEPRECATED // DEPRECATED case 'memcache': $sparams['hashtable'] = $injector->getInstance('Horde_Core_HashTable_Wrapper'); $driver = 'Horde_Cache_Storage_Hashtable'; unset($sparams['driverconfig'], $sparams['umask']); break; case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'cache'); if ($nosql instanceof Horde_Mongo_Client) { $sparams['mongo_db'] = $nosql; $driver = 'Horde_Cache_Storage_Mongo'; } else { $driver = 'Horde_Cache_Storage_Null'; } unset($sparams['driverconfig'], $sparams['umask']); break; case 'sql': $sparams['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'cache'); unset($sparams['driverconfig'], $sparams['umask']); break; } $storage = $this->storage = $this->_getStorage($driver, $sparams); if (!empty($conf['cache']['use_memorycache']) && in_array($driver, array('file', 'sql'))) { switch (Horde_String::lower($conf['cache']['use_memorycache'])) { case 'hashtable': case 'memcache': $storage = new Horde_Cache_Storage_Stack(array('stack' => array($this->_getStorage($conf['cache']['use_memorycache'], array('hashtable' => $injector->getInstance('Horde_Core_HashTable_Wrapper'))), $storage))); break; } } return new Horde_Cache($storage, $params); }
/** * Provide a mock server. * * @return Horde_Kolab_Server The mock server. */ protected function getMockServer() { $injector = new Horde_Injector(new Horde_Injector_TopLevel()); $config = new stdClass(); $config->driver = 'none'; $injector->setInstance('Horde_Kolab_Server_Config', $config); $injector->bindFactory('Horde_Kolab_Server_Structure', 'Horde_Kolab_Server_Factory', 'getStructure'); $injector->bindFactory('Horde_Kolab_Server', 'Horde_Kolab_Server_Factory', 'getServer'); return $injector->getInstance('Horde_Kolab_Server'); }
/** * Return the IMP_Maillog instance. * * @return IMP_Maillog The singleton instance. */ public function create(Horde_Injector $injector) { global $conf, $injector, $registry; $storage = array(); if ($injector->getInstance('IMP_Factory_Imap')->create()->isImap()) { $storage[] = new IMP_Maillog_Storage_Mdnsent(); } $driver = isset($conf['maillog']['driver']) ? $conf['maillog']['driver'] : 'none'; switch ($driver) { case 'history': $storage[] = new IMP_Maillog_Storage_History($injector->getInstance('Horde_History'), $registry->getAuth()); break; case 'none': default: $storage[] = new IMP_Maillog_Storage_Null(); break; } return new IMP_Maillog(count($storage) > 1 ? new IMP_Maillog_Storage_Composite($storage) : reset($storage)); }