Author: Bob Mckee (bmckee@bywires.com)
Author: Chuck Hagenbuch (chuck@horde.org)
Inheritance: implements Horde_Autoloader_ClassPathMapper
Example #1
0
 /**
  * Retrieve an API object.
  *
  * @param string $app   The application to load.
  * @param string $type  Either 'application' or 'api'.
  *
  * @return Horde_Registry_Api|Horde_Registry_Application  The API object.
  * @throws Horde_Exception
  */
 public function getApiInstance($app, $type)
 {
     if (isset($this->_cache['ob'][$app][$type])) {
         return $this->_cache['ob'][$app][$type];
     }
     $path = $this->get('fileroot', $app) . '/lib';
     /* Set up autoload paths for the current application. This needs to
      * be done here because it is possible to try to load app-specific
      * libraries from other applications. */
     if (!isset($this->_cache['ob'][$app])) {
         $autoloader = $GLOBALS['injector']->getInstance('Horde_Autoloader');
         $app_mappers = array('Controller' => 'controllers', 'Helper' => 'helpers', 'SettingsExporter' => 'settings');
         $applicationMapper = new Horde_Autoloader_ClassPathMapper_Application($this->get('fileroot', $app) . '/app');
         foreach ($app_mappers as $key => $val) {
             $applicationMapper->addMapping($key, $val);
         }
         $autoloader->addClassPathMapper($applicationMapper);
         /* Skip horde, since this was already setup in core.php. */
         if ($app != 'horde') {
             $autoloader->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_PrefixString($app, $path));
         }
     }
     $cname = Horde_String::ucfirst($type);
     /* Can't autoload here, since the application may not have been
      * initialized yet. */
     $classname = Horde_String::ucfirst($app) . '_' . $cname;
     $path = $path . '/' . $cname . '.php';
     if (file_exists($path)) {
         include_once $path;
     } else {
         $classname = __CLASS__ . '_' . $cname;
     }
     if (!class_exists($classname, false)) {
         throw new Horde_Exception("{$app} does not have an API");
     }
     $this->_cache['ob'][$app][$type] = $type == 'application' ? new $classname($app) : new $classname();
     return $this->_cache['ob'][$app][$type];
 }
Example #2
0
<?php

require_once dirname(__FILE__) . '/../../config/conf.php';
require_once HORDE_BASE . '/lib/core.php';
$session_control = 'none';
$nocompress = true;
Horde_Registry::appInit('horde', array('authentication' => 'none', 'nocompress' => $nocompress, 'session_control' => $session_control));
$GLOBALS['injector']->getInstance('Horde_Autoloader')->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Default($fs_base . '/app/lib/'));
$applicationMapper = new Horde_Autoloader_ClassPathMapper_Application($fs_base . '/app');
$applicationMapper->addMapping('Controller', 'controllers');
$applicationMapper->addMapping('SettingsExporter', 'settings');
$__autoloader->addClassPathMapper($applicationMapper);
$myMapper = new Horde_Autoloader_ClassPathMapper_Prefix('/^HordeWeb_/', $fs_base . '/app/lib/HordeWeb');
$__autoloader->addClassPathMapper($myMapper);
/* Binders */
$GLOBALS['injector']->bindFactory('HordeWeb_View', 'HordeWeb_Factory_View', 'create');
$registry = $GLOBALS['injector']->getInstance('Horde_Registry');
$mapper = $GLOBALS['injector']->getInstance('Horde_Routes_Mapper');
require_once dirname(__FILE__) . '/../../config/routes.php';