当前位置: 首页>>代码示例>>PHP>>正文


PHP Horde_Injector::getInstance方法代码示例

本文整理汇总了PHP中Horde_Injector::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Injector::getInstance方法的具体用法?PHP Horde_Injector::getInstance怎么用?PHP Horde_Injector::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Horde_Injector的用法示例。


在下文中一共展示了Horde_Injector::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * 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];
 }
开发者ID:horde,项目名称:horde,代码行数:35,代码来源:Driver.php

示例2: create

 /**
  * 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];
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:31,代码来源:Tasklists.php

示例3: _factory

 /**
  * 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);
 }
开发者ID:horde,项目名称:horde,代码行数:36,代码来源:Imsp.php

示例4: create

 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);
 }
开发者ID:horde,项目名称:horde,代码行数:30,代码来源:Group.php

示例5: create

 /**
  * 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];
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:35,代码来源:Driver.php

示例6: create

 /**
  * @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;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:33,代码来源:History.php

示例7: create

 /**
  * @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);
     }
 }
开发者ID:horde,项目名称:horde,代码行数:32,代码来源:Weather.php

示例8: create

 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);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:31,代码来源:Token.php

示例9: create

 /**
  * 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];
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:36,代码来源:Driver.php

示例10: create

 /**
  * 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];
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:15,代码来源:Storage.php

示例11: getDb

 /**
  * 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);
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:20,代码来源:Driver.php

示例12: create

 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);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:13,代码来源:ActiveSyncBackend.php

示例13: getRequestConfiguration

 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;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:49,代码来源:RequestMapper.php

示例14: create

 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.');
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:15,代码来源:ActiveSyncState.php

示例15: create

 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;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:15,代码来源:ActiveSyncServer.php


注:本文中的Horde_Injector::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。