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


PHP Horde_Injector类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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':
             $params['apikey'] = $conf['weather']['params']['key'];
             break;
         case 'Google':
             $l = explode('_', $GLOBALS['language']);
             $params['language'] = $l[0];
             break;
     }
     $class = $this->_getDriverName($driver, 'Horde_Service_Weather');
     try {
         return new $class($params);
     } catch (InvalidArgumentException $e) {
         throw new Horde_Exception($e);
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:29,代码来源:Weather.php

示例4: testMock

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

示例5: 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

示例6: create

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

示例7: 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

示例8: create

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

示例9: getParameterDependency

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

示例10: create

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

示例11: 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

示例12: create

 /**
  * Return the IMP_Crypt_Pgp instance.
  *
  * @return IMP_Crypt_Pgp  The singleton instance.
  */
 public function create(Horde_Injector $injector)
 {
     $params = array('program' => $GLOBALS['conf']['gnupg']['path']);
     if (isset($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
         $params['proxy_host'] = $GLOBALS['conf']['http']['proxy']['proxy_host'];
         if (isset($GLOBALS['conf']['http']['proxy']['proxy_port'])) {
             $params['proxy_port'] = $GLOBALS['conf']['http']['proxy']['proxy_port'];
         }
     }
     return $injector->getInstance('Horde_Core_Factory_Crypt')->create('IMP_Crypt_Pgp', $params);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:16,代码来源:Pgp.php

示例13: 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

示例14: _getFactory

 private function _getFactory()
 {
     $GLOBALS['conf']['kolab']['server']['basedn'] = 'test';
     $injector = new Horde_Injector(new Horde_Injector_TopLevel());
     $server_factory = new Horde_Core_Factory_KolabServer($injector);
     $factory = new Horde_Core_Factory_KolabSession($injector);
     $this->session_auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
     $this->session_storage = $this->getMock('Horde_Kolab_Session_Storage_Interface');
     $injector->setInstance('Horde_Kolab_Session_Auth_Interface', $this->session_auth);
     $injector->setInstance('Horde_Kolab_Session_Storage_Interface', $this->session_storage);
     return $factory;
 }
开发者ID:horde,项目名称:horde,代码行数:12,代码来源:KolabSessionTest.php

示例15: create

 public function create(Horde_Injector $injector)
 {
     // Set up a view with the shared template path.
     // Individual controlles will set the specific path for their view.
     // @TODO: GLOBALS should be moved to a site_config object obtained via
     // the injector and injected into each class that needs them.
     $view = $injector->getInstance('Horde_View');
     $view->addHelper('Tag');
     $view->addHelper('Url');
     $view->addTemplatePath(array($GLOBALS['fs_base'] . '/app/views/shared', $GLOBALS['fs_base'] . '/app/views/partials', $GLOBALS['fs_base'] . '/app/views/layout'));
     return $view;
 }
开发者ID:horde,项目名称:horde-web,代码行数:12,代码来源:View.php


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