Esempio n. 1
0
 public function __construct(Horde_Injector $injector = null)
 {
     if ($injector === null) {
         $this->_injector = new Horde_Injector(new Horde_Injector_TopLevel());
         $this->_injector->bindFactory('Horde_Log_Logger', 'Horde_Kolab_Filter_Factory', 'getLogger');
         $this->_injector->bindFactory('Horde_Kolab_Server_Composite', 'Horde_Kolab_Filter_Factory', 'getUserDb');
         $this->_injector->bindImplementation('Horde_Kolab_Filter_Temporary', 'Horde_Kolab_Filter_Temporary_File');
         $this->_injector->setInstance('Horde_Kolab_Filter', $this);
     } else {
         $this->_injector = $injector;
     }
 }
Esempio n. 2
0
 /**
  * Setup the basic injector bindings.
  *
  * @return NULL
  */
 public function bindings()
 {
     $this->_injector->bindImplementation('Horde_Kolab_FreeBusy_Factory', $this->_factory);
     $this->_injector->bindFactory('Horde_Routes_Mapper', $this->_factory, 'createMapper');
     $this->_injector->bindFactory('Horde_Kolab_FreeBusy_Controller_RequestConfiguration', $this->_factory, 'createRequestConfiguration');
     $this->_injector->bindFactory('Horde_Controller_Request', $this->_factory, 'createRequest');
     $this->_injector->bindFactory('Horde_View_Base', $this->_factory, 'createView');
     $this->_injector->bindFactory('Horde_Controller_ResponseWriter', $this->_factory, 'createResponseWriter');
     $this->_injector->bindFactory('Horde_Log_Logger', $this->_factory, 'createLogger');
     $this->_injector->bindFactory('Horde_Kolab_FreeBusy_User', $this->_factory, 'createUser');
     $this->_injector->bindFactory('Horde_Kolab_FreeBusy_Owner', $this->_factory, 'createOwner');
     $this->_injector->bindFactory('Horde_Kolab_FreeBusy_Resource', $this->_factory, 'createResource');
     $this->_injector->bindFactory('Horde_Kolab_FreeBusy_Provider', $this->_factory, 'createProvider');
 }
Esempio n. 3
0
 /**
  * Constructor.
  *
  * @param Horde_Injector $injector The injector providing required dependencies.
  */
 public function __construct(Horde_Injector $injector)
 {
     $injector->bindImplementation('Horde_Kolab_FreeBusy_Params_Owner', 'Horde_Kolab_FreeBusy_Freebusy_Params_Folder');
     parent::__construct($injector);
 }
Esempio n. 4
0
 /**
  * Create a new Horde_Registry instance.
  *
  * @param integer $session_flags  Any session flags.
  * @param array $args             See appInit().
  *
  * @throws Horde_Exception
  */
 public function __construct($session_flags = 0, array $args = array())
 {
     /* Set a valid timezone. */
     date_default_timezone_set(ini_get('date.timezone') ?: getenv('TZ') ?: 'UTC');
     /* Save arguments. */
     $this->_args = $args;
     /* Define factories. By default, uses the 'create' method in the given
      * classname (string). If other function needed, define as the second
      * element in an array. */
     $factories = array('Horde_ActiveSyncBackend' => 'Horde_Core_Factory_ActiveSyncBackend', 'Horde_ActiveSyncServer' => 'Horde_Core_Factory_ActiveSyncServer', 'Horde_ActiveSyncState' => 'Horde_Core_Factory_ActiveSyncState', 'Horde_Alarm' => 'Horde_Core_Factory_Alarm', 'Horde_Browser' => 'Horde_Core_Factory_Browser', 'Horde_Cache' => 'Horde_Core_Factory_Cache', 'Horde_Controller_Request' => 'Horde_Core_Factory_Request', 'Horde_Controller_RequestConfiguration' => array('Horde_Core_Controller_RequestMapper', 'getRequestConfiguration'), 'Horde_Core_Auth_Signup' => 'Horde_Core_Factory_AuthSignup', 'Horde_Core_CssCache' => 'Horde_Core_Factory_CssCache', 'Horde_Core_JavascriptCache' => 'Horde_Core_Factory_JavascriptCache', 'Horde_Core_Perms' => 'Horde_Core_Factory_PermsCore', 'Horde_Dav_Server' => 'Horde_Core_Factory_DavServer', 'Horde_Dav_Storage' => 'Horde_Core_Factory_DavStorage', 'Horde_Db_Adapter' => 'Horde_Core_Factory_DbBase', 'Horde_Editor' => 'Horde_Core_Factory_Editor', 'Horde_ElasticSearch_Client' => 'Horde_Core_Factory_ElasticSearch', 'Horde_Group' => 'Horde_Core_Factory_Group', 'Horde_HashTable' => 'Horde_Core_Factory_HashTable', 'Horde_History' => 'Horde_Core_Factory_History', 'Horde_Kolab_Server_Composite' => 'Horde_Core_Factory_KolabServer', 'Horde_Kolab_Session' => 'Horde_Core_Factory_KolabSession', 'Horde_Kolab_Storage' => 'Horde_Core_Factory_KolabStorage', 'Horde_Lock' => 'Horde_Core_Factory_Lock', 'Horde_Log_Logger' => 'Horde_Core_Factory_Logger', 'Horde_Mail' => 'Horde_Core_Factory_MailBase', 'Horde_Memcache' => 'Horde_Core_Factory_Memcache', 'Horde_Nosql_Adapter' => 'Horde_Core_Factory_NosqlBase', 'Horde_Notification' => 'Horde_Core_Factory_Notification', 'Horde_Perms' => 'Horde_Core_Factory_Perms', 'Horde_Queue_Storage' => 'Horde_Core_Factory_QueueStorage', 'Horde_Routes_Mapper' => 'Horde_Core_Factory_Mapper', 'Horde_Routes_Matcher' => 'Horde_Core_Factory_Matcher', 'Horde_Secret' => 'Horde_Core_Factory_Secret', 'Horde_Secret_Cbc' => 'Horde_Core_Factory_Secret_Cbc', 'Horde_Service_Facebook' => 'Horde_Core_Factory_Facebook', 'Horde_Service_Twitter' => 'Horde_Core_Factory_Twitter', 'Horde_Service_UrlShortener' => 'Horde_Core_Factory_UrlShortener', 'Horde_SessionHandler' => 'Horde_Core_Factory_SessionHandler', 'Horde_Template' => 'Horde_Core_Factory_Template', 'Horde_Timezone' => 'Horde_Core_Factory_Timezone', 'Horde_Token' => 'Horde_Core_Factory_Token', 'Horde_Variables' => 'Horde_Core_Factory_Variables', 'Horde_View' => 'Horde_Core_Factory_View', 'Horde_View_Base' => 'Horde_Core_Factory_View', 'Horde_Weather' => 'Horde_Core_Factory_Weather', 'Net_DNS2_Resolver' => 'Horde_Core_Factory_Dns', 'Text_LanguageDetect' => 'Horde_Core_Factory_LanguageDetect');
     /* Define implementations. */
     $implementations = array('Horde_Controller_ResponseWriter' => 'Horde_Controller_ResponseWriter_Web');
     /* Setup injector. */
     $GLOBALS['injector'] = $injector = new Horde_Injector(new Horde_Injector_TopLevel());
     foreach ($factories as $key => $val) {
         if (is_string($val)) {
             $val = array($val, 'create');
         }
         $injector->bindFactory($key, $val[0], $val[1]);
     }
     foreach ($implementations as $key => $val) {
         $injector->bindImplementation($key, $val);
     }
     $GLOBALS['registry'] = $this;
     $injector->setInstance(__CLASS__, $this);
     /* Setup autoloader instance. */
     $injector->setInstance('Horde_Autoloader', $GLOBALS['__autoloader']);
     /* Import and global Horde's configuration values. */
     $this->importConfig('horde');
     $conf = $GLOBALS['conf'];
     /* Set the umask according to config settings. */
     if (isset($conf['umask'])) {
         umask($conf['umask']);
     }
     /* Set the error reporting level in accordance with the config
      * settings. */
     error_reporting($conf['debug_level']);
     /* Set the maximum execution time in accordance with the config
      * settings, but only if not running from the CLI */
     if (!isset($GLOBALS['cli'])) {
         set_time_limit($conf['max_exec_time']);
     }
     /* The basic framework is up and loaded, so set the init flag. */
     $this->hordeInit = true;
     /* Initial Horde-wide settings. */
     /* Initialize browser object. */
     $GLOBALS['browser'] = $injector->getInstance('Horde_Browser');
     /* Get modified time of registry files. */
     $regfiles = array(HORDE_BASE . '/config/registry.php', HORDE_BASE . '/config/registry.d');
     if (file_exists(HORDE_BASE . '/config/registry.local.php')) {
         $regfiles[] = HORDE_BASE . '/config/registry.local.php';
     }
     if (!empty($conf['vhosts'])) {
         $vhost = HORDE_BASE . '/config/registry-' . $conf['server']['name'] . '.php';
         if (file_exists($vhost)) {
             $regfiles[] = $this->vhost = $vhost;
         }
     }
     $this->_regmtime = max(array_map('filemtime', $regfiles));
     /* Start a session. */
     if ($session_flags & self::SESSION_NONE) {
         /* Never start a session if the session flags include
            SESSION_NONE. */
         $GLOBALS['session'] = $session = new Horde_Session_Null();
         $session->setup(true, $args['session_cache_limiter']);
     } elseif (PHP_SAPI === 'cli' || empty($_SERVER['SERVER_NAME']) && (PHP_SAPI === 'cgi' || PHP_SAPI === 'cgi-fcgi')) {
         $GLOBALS['session'] = $session = new Horde_Session();
         $session->setup(false, $args['session_cache_limiter']);
     } else {
         $GLOBALS['session'] = $session = new Horde_Session();
         $session->setup(true, $args['session_cache_limiter']);
         if ($session_flags & self::SESSION_READONLY) {
             /* Close the session immediately so no changes can be made but
                values are still available. */
             $session->close();
         }
     }
     $injector->setInstance('Horde_Session', $session);
     /* Always need to load applications information. */
     $this->_loadApplications();
     /* Stop system if Horde is inactive. */
     if ($this->applications['horde']['status'] == 'inactive') {
         throw new Horde_Exception(Horde_Core_Translation::t("This system is currently deactivated."));
     }
     /* Initialize language configuration object. */
     $this->nlsconfig = new Horde_Registry_Nlsconfig();
     /* Initialize the localization routines and variables. */
     $this->setLanguageEnvironment(null, 'horde');
     /* Initialize global page output object. */
     $GLOBALS['page_output'] = $injector->getInstance('Horde_PageOutput');
     /* Initialize notification object. Always attach status listener by
      * default. */
     $nclass = null;
     switch ($this->getView()) {
         case self::VIEW_DYNAMIC:
             $nclass = 'Horde_Core_Notification_Listener_DynamicStatus';
             break;
         case self::VIEW_SMARTMOBILE:
             $nclass = 'Horde_Core_Notification_Listener_SmartmobileStatus';
             break;
     }
     $GLOBALS['notification'] = $injector->getInstance('Horde_Notification');
     if (empty($args['nonotificationinit'])) {
         $GLOBALS['notification']->attachAllAppHandlers();
     }
     $GLOBALS['notification']->attach('status', null, $nclass);
     Horde_Shutdown::add($this);
 }
Esempio n. 5
0
 /**
  * Constructor.
  *
  * @param Horde_Injector $injector The injector providing required dependencies.
  */
 public function __construct(Horde_Injector $injector)
 {
     $injector->bindImplementation('Horde_Kolab_FreeBusy_UserDb', 'Horde_Kolab_FreeBusy_UserDb_Kolab');
     parent::__construct($injector);
 }
Esempio n. 6
0
require 'Horde/Autoloader.php';
interface Person
{
    public function __toString();
}
class World implements Person
{
    public function __toString()
    {
        return 'World';
    }
}
interface Greeter
{
    public function greet();
}
class Hello implements Greeter
{
    public function __construct(Person $somebody)
    {
        $this->somebody = $somebody;
    }
    public function greet()
    {
        print 'Hello ' . $this->somebody;
    }
}
$a = new Horde_Injector(new Horde_Injector_TopLevel());
$a->bindImplementation('Person', 'World');
$a->bindImplementation('Greeter', 'Hello');
$a->getInstance('Greeter')->greet();